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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.Types.ComparisonOperator
import Amazonka.WAFRegional.Types.FieldToMatch
import Amazonka.WAFRegional.Types.TextTransformation

-- | 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 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.
--
-- /See:/ 'newSizeConstraint' smart constructor.
data SizeConstraint = SizeConstraint'
  { -- | Specifies where in a web request to look for the size constraint.
    SizeConstraint -> FieldToMatch
fieldToMatch :: FieldToMatch,
    -- | Text transformations eliminate some of the unusual formatting that
    -- attackers use in web requests in an effort to bypass AWS WAF. If you
    -- specify a transformation, AWS WAF performs the transformation on
    -- @FieldToMatch@ before inspecting it for a match.
    --
    -- You can only specify a single type of TextTransformation.
    --
    -- Note that if you choose @BODY@ for the value of @Type@, you must choose
    -- @NONE@ for @TextTransformation@ because CloudFront forwards only the
    -- first 8192 bytes for inspection.
    --
    -- __NONE__
    --
    -- Specify @NONE@ if you don\'t want to perform any text transformations.
    --
    -- __CMD_LINE__
    --
    -- When you\'re concerned that attackers are injecting an operating system
    -- command line command and using unusual formatting to disguise some or
    -- all of the command, use this option to perform the following
    -- transformations:
    --
    -- -   Delete the following characters: \\ \" \' ^
    --
    -- -   Delete spaces before the following characters: \/ (
    --
    -- -   Replace the following characters with a space: , ;
    --
    -- -   Replace multiple spaces with one space
    --
    -- -   Convert uppercase letters (A-Z) to lowercase (a-z)
    --
    -- __COMPRESS_WHITE_SPACE__
    --
    -- Use this option to replace the following characters with a space
    -- character (decimal 32):
    --
    -- -   \\f, formfeed, decimal 12
    --
    -- -   \\t, tab, decimal 9
    --
    -- -   \\n, newline, decimal 10
    --
    -- -   \\r, carriage return, decimal 13
    --
    -- -   \\v, vertical tab, decimal 11
    --
    -- -   non-breaking space, decimal 160
    --
    -- @COMPRESS_WHITE_SPACE@ also replaces multiple spaces with one space.
    --
    -- __HTML_ENTITY_DECODE__
    --
    -- Use this option to replace HTML-encoded characters with unencoded
    -- characters. @HTML_ENTITY_DECODE@ performs the following operations:
    --
    -- -   Replaces @(ampersand)quot;@ with @\"@
    --
    -- -   Replaces @(ampersand)nbsp;@ with a non-breaking space, decimal 160
    --
    -- -   Replaces @(ampersand)lt;@ with a \"less than\" symbol
    --
    -- -   Replaces @(ampersand)gt;@ with @>@
    --
    -- -   Replaces characters that are represented in hexadecimal format,
    --     @(ampersand)#xhhhh;@, with the corresponding characters
    --
    -- -   Replaces characters that are represented in decimal format,
    --     @(ampersand)#nnnn;@, with the corresponding characters
    --
    -- __LOWERCASE__
    --
    -- Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
    --
    -- __URL_DECODE__
    --
    -- Use this option to decode a URL-encoded value.
    SizeConstraint -> TextTransformation
textTransformation :: TextTransformation,
    -- | The type of comparison you want AWS WAF to perform. AWS WAF uses this in
    -- combination with the provided @Size@ 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.
    --
    -- __EQ__: Used to test if the @Size@ is equal to the size of the
    -- @FieldToMatch@
    --
    -- __NE__: Used to test if the @Size@ is not equal to the size of the
    -- @FieldToMatch@
    --
    -- __LE__: Used to test if the @Size@ is less than or equal to the size of
    -- the @FieldToMatch@
    --
    -- __LT__: Used to test if the @Size@ is strictly less than the size of the
    -- @FieldToMatch@
    --
    -- __GE__: Used to test if the @Size@ is greater than or equal to the size
    -- of the @FieldToMatch@
    --
    -- __GT__: Used to test if the @Size@ is strictly greater than the size of
    -- the @FieldToMatch@
    SizeConstraint -> ComparisonOperator
comparisonOperator :: ComparisonOperator,
    -- | The size in bytes that you want AWS WAF to compare against the size of
    -- the specified @FieldToMatch@. AWS WAF uses this in combination with
    -- @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.
    --
    -- Valid values for size are 0 - 21474836480 bytes (0 - 20 GB).
    --
    -- If you specify @URI@ for the value of @Type@, the \/ in the URI counts
    -- as one character. For example, the URI @\/logo.jpg@ is nine characters
    -- long.
    SizeConstraint -> Natural
size :: Prelude.Natural
  }
  deriving (SizeConstraint -> SizeConstraint -> Bool
(SizeConstraint -> SizeConstraint -> Bool)
-> (SizeConstraint -> SizeConstraint -> Bool) -> Eq SizeConstraint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SizeConstraint -> SizeConstraint -> Bool
$c/= :: SizeConstraint -> SizeConstraint -> Bool
== :: SizeConstraint -> SizeConstraint -> Bool
$c== :: SizeConstraint -> SizeConstraint -> Bool
Prelude.Eq, ReadPrec [SizeConstraint]
ReadPrec SizeConstraint
Int -> ReadS SizeConstraint
ReadS [SizeConstraint]
(Int -> ReadS SizeConstraint)
-> ReadS [SizeConstraint]
-> ReadPrec SizeConstraint
-> ReadPrec [SizeConstraint]
-> Read SizeConstraint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SizeConstraint]
$creadListPrec :: ReadPrec [SizeConstraint]
readPrec :: ReadPrec SizeConstraint
$creadPrec :: ReadPrec SizeConstraint
readList :: ReadS [SizeConstraint]
$creadList :: ReadS [SizeConstraint]
readsPrec :: Int -> ReadS SizeConstraint
$creadsPrec :: Int -> ReadS SizeConstraint
Prelude.Read, Int -> SizeConstraint -> ShowS
[SizeConstraint] -> ShowS
SizeConstraint -> String
(Int -> SizeConstraint -> ShowS)
-> (SizeConstraint -> String)
-> ([SizeConstraint] -> ShowS)
-> Show SizeConstraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SizeConstraint] -> ShowS
$cshowList :: [SizeConstraint] -> ShowS
show :: SizeConstraint -> String
$cshow :: SizeConstraint -> String
showsPrec :: Int -> SizeConstraint -> ShowS
$cshowsPrec :: Int -> SizeConstraint -> ShowS
Prelude.Show, (forall x. SizeConstraint -> Rep SizeConstraint x)
-> (forall x. Rep SizeConstraint x -> SizeConstraint)
-> Generic SizeConstraint
forall x. Rep SizeConstraint x -> SizeConstraint
forall x. SizeConstraint -> Rep SizeConstraint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SizeConstraint x -> SizeConstraint
$cfrom :: forall x. SizeConstraint -> Rep SizeConstraint x
Prelude.Generic)

-- |
-- Create a value of 'SizeConstraint' 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:
--
-- 'fieldToMatch', 'sizeConstraint_fieldToMatch' - Specifies where in a web request to look for the size constraint.
--
-- 'textTransformation', 'sizeConstraint_textTransformation' - Text transformations eliminate some of the unusual formatting that
-- attackers use in web requests in an effort to bypass AWS WAF. If you
-- specify a transformation, AWS WAF performs the transformation on
-- @FieldToMatch@ before inspecting it for a match.
--
-- You can only specify a single type of TextTransformation.
--
-- Note that if you choose @BODY@ for the value of @Type@, you must choose
-- @NONE@ for @TextTransformation@ because CloudFront forwards only the
-- first 8192 bytes for inspection.
--
-- __NONE__
--
-- Specify @NONE@ if you don\'t want to perform any text transformations.
--
-- __CMD_LINE__
--
-- When you\'re concerned that attackers are injecting an operating system
-- command line command and using unusual formatting to disguise some or
-- all of the command, use this option to perform the following
-- transformations:
--
-- -   Delete the following characters: \\ \" \' ^
--
-- -   Delete spaces before the following characters: \/ (
--
-- -   Replace the following characters with a space: , ;
--
-- -   Replace multiple spaces with one space
--
-- -   Convert uppercase letters (A-Z) to lowercase (a-z)
--
-- __COMPRESS_WHITE_SPACE__
--
-- Use this option to replace the following characters with a space
-- character (decimal 32):
--
-- -   \\f, formfeed, decimal 12
--
-- -   \\t, tab, decimal 9
--
-- -   \\n, newline, decimal 10
--
-- -   \\r, carriage return, decimal 13
--
-- -   \\v, vertical tab, decimal 11
--
-- -   non-breaking space, decimal 160
--
-- @COMPRESS_WHITE_SPACE@ also replaces multiple spaces with one space.
--
-- __HTML_ENTITY_DECODE__
--
-- Use this option to replace HTML-encoded characters with unencoded
-- characters. @HTML_ENTITY_DECODE@ performs the following operations:
--
-- -   Replaces @(ampersand)quot;@ with @\"@
--
-- -   Replaces @(ampersand)nbsp;@ with a non-breaking space, decimal 160
--
-- -   Replaces @(ampersand)lt;@ with a \"less than\" symbol
--
-- -   Replaces @(ampersand)gt;@ with @>@
--
-- -   Replaces characters that are represented in hexadecimal format,
--     @(ampersand)#xhhhh;@, with the corresponding characters
--
-- -   Replaces characters that are represented in decimal format,
--     @(ampersand)#nnnn;@, with the corresponding characters
--
-- __LOWERCASE__
--
-- Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
--
-- __URL_DECODE__
--
-- Use this option to decode a URL-encoded value.
--
-- 'comparisonOperator', 'sizeConstraint_comparisonOperator' - The type of comparison you want AWS WAF to perform. AWS WAF uses this in
-- combination with the provided @Size@ 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.
--
-- __EQ__: Used to test if the @Size@ is equal to the size of the
-- @FieldToMatch@
--
-- __NE__: Used to test if the @Size@ is not equal to the size of the
-- @FieldToMatch@
--
-- __LE__: Used to test if the @Size@ is less than or equal to the size of
-- the @FieldToMatch@
--
-- __LT__: Used to test if the @Size@ is strictly less than the size of the
-- @FieldToMatch@
--
-- __GE__: Used to test if the @Size@ is greater than or equal to the size
-- of the @FieldToMatch@
--
-- __GT__: Used to test if the @Size@ is strictly greater than the size of
-- the @FieldToMatch@
--
-- 'size', 'sizeConstraint_size' - The size in bytes that you want AWS WAF to compare against the size of
-- the specified @FieldToMatch@. AWS WAF uses this in combination with
-- @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.
--
-- Valid values for size are 0 - 21474836480 bytes (0 - 20 GB).
--
-- If you specify @URI@ for the value of @Type@, the \/ in the URI counts
-- as one character. For example, the URI @\/logo.jpg@ is nine characters
-- long.
newSizeConstraint ::
  -- | 'fieldToMatch'
  FieldToMatch ->
  -- | 'textTransformation'
  TextTransformation ->
  -- | 'comparisonOperator'
  ComparisonOperator ->
  -- | 'size'
  Prelude.Natural ->
  SizeConstraint
newSizeConstraint :: FieldToMatch
-> TextTransformation
-> ComparisonOperator
-> Natural
-> SizeConstraint
newSizeConstraint
  FieldToMatch
pFieldToMatch_
  TextTransformation
pTextTransformation_
  ComparisonOperator
pComparisonOperator_
  Natural
pSize_ =
    SizeConstraint' :: FieldToMatch
-> TextTransformation
-> ComparisonOperator
-> Natural
-> SizeConstraint
SizeConstraint'
      { $sel:fieldToMatch:SizeConstraint' :: FieldToMatch
fieldToMatch = FieldToMatch
pFieldToMatch_,
        $sel:textTransformation:SizeConstraint' :: TextTransformation
textTransformation = TextTransformation
pTextTransformation_,
        $sel:comparisonOperator:SizeConstraint' :: ComparisonOperator
comparisonOperator = ComparisonOperator
pComparisonOperator_,
        $sel:size:SizeConstraint' :: Natural
size = Natural
pSize_
      }

-- | Specifies where in a web request to look for the size constraint.
sizeConstraint_fieldToMatch :: Lens.Lens' SizeConstraint FieldToMatch
sizeConstraint_fieldToMatch :: (FieldToMatch -> f FieldToMatch)
-> SizeConstraint -> f SizeConstraint
sizeConstraint_fieldToMatch = (SizeConstraint -> FieldToMatch)
-> (SizeConstraint -> FieldToMatch -> SizeConstraint)
-> Lens SizeConstraint SizeConstraint FieldToMatch FieldToMatch
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SizeConstraint' {FieldToMatch
fieldToMatch :: FieldToMatch
$sel:fieldToMatch:SizeConstraint' :: SizeConstraint -> FieldToMatch
fieldToMatch} -> FieldToMatch
fieldToMatch) (\s :: SizeConstraint
s@SizeConstraint' {} FieldToMatch
a -> SizeConstraint
s {$sel:fieldToMatch:SizeConstraint' :: FieldToMatch
fieldToMatch = FieldToMatch
a} :: SizeConstraint)

-- | Text transformations eliminate some of the unusual formatting that
-- attackers use in web requests in an effort to bypass AWS WAF. If you
-- specify a transformation, AWS WAF performs the transformation on
-- @FieldToMatch@ before inspecting it for a match.
--
-- You can only specify a single type of TextTransformation.
--
-- Note that if you choose @BODY@ for the value of @Type@, you must choose
-- @NONE@ for @TextTransformation@ because CloudFront forwards only the
-- first 8192 bytes for inspection.
--
-- __NONE__
--
-- Specify @NONE@ if you don\'t want to perform any text transformations.
--
-- __CMD_LINE__
--
-- When you\'re concerned that attackers are injecting an operating system
-- command line command and using unusual formatting to disguise some or
-- all of the command, use this option to perform the following
-- transformations:
--
-- -   Delete the following characters: \\ \" \' ^
--
-- -   Delete spaces before the following characters: \/ (
--
-- -   Replace the following characters with a space: , ;
--
-- -   Replace multiple spaces with one space
--
-- -   Convert uppercase letters (A-Z) to lowercase (a-z)
--
-- __COMPRESS_WHITE_SPACE__
--
-- Use this option to replace the following characters with a space
-- character (decimal 32):
--
-- -   \\f, formfeed, decimal 12
--
-- -   \\t, tab, decimal 9
--
-- -   \\n, newline, decimal 10
--
-- -   \\r, carriage return, decimal 13
--
-- -   \\v, vertical tab, decimal 11
--
-- -   non-breaking space, decimal 160
--
-- @COMPRESS_WHITE_SPACE@ also replaces multiple spaces with one space.
--
-- __HTML_ENTITY_DECODE__
--
-- Use this option to replace HTML-encoded characters with unencoded
-- characters. @HTML_ENTITY_DECODE@ performs the following operations:
--
-- -   Replaces @(ampersand)quot;@ with @\"@
--
-- -   Replaces @(ampersand)nbsp;@ with a non-breaking space, decimal 160
--
-- -   Replaces @(ampersand)lt;@ with a \"less than\" symbol
--
-- -   Replaces @(ampersand)gt;@ with @>@
--
-- -   Replaces characters that are represented in hexadecimal format,
--     @(ampersand)#xhhhh;@, with the corresponding characters
--
-- -   Replaces characters that are represented in decimal format,
--     @(ampersand)#nnnn;@, with the corresponding characters
--
-- __LOWERCASE__
--
-- Use this option to convert uppercase letters (A-Z) to lowercase (a-z).
--
-- __URL_DECODE__
--
-- Use this option to decode a URL-encoded value.
sizeConstraint_textTransformation :: Lens.Lens' SizeConstraint TextTransformation
sizeConstraint_textTransformation :: (TextTransformation -> f TextTransformation)
-> SizeConstraint -> f SizeConstraint
sizeConstraint_textTransformation = (SizeConstraint -> TextTransformation)
-> (SizeConstraint -> TextTransformation -> SizeConstraint)
-> Lens
     SizeConstraint SizeConstraint TextTransformation TextTransformation
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SizeConstraint' {TextTransformation
textTransformation :: TextTransformation
$sel:textTransformation:SizeConstraint' :: SizeConstraint -> TextTransformation
textTransformation} -> TextTransformation
textTransformation) (\s :: SizeConstraint
s@SizeConstraint' {} TextTransformation
a -> SizeConstraint
s {$sel:textTransformation:SizeConstraint' :: TextTransformation
textTransformation = TextTransformation
a} :: SizeConstraint)

-- | The type of comparison you want AWS WAF to perform. AWS WAF uses this in
-- combination with the provided @Size@ 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.
--
-- __EQ__: Used to test if the @Size@ is equal to the size of the
-- @FieldToMatch@
--
-- __NE__: Used to test if the @Size@ is not equal to the size of the
-- @FieldToMatch@
--
-- __LE__: Used to test if the @Size@ is less than or equal to the size of
-- the @FieldToMatch@
--
-- __LT__: Used to test if the @Size@ is strictly less than the size of the
-- @FieldToMatch@
--
-- __GE__: Used to test if the @Size@ is greater than or equal to the size
-- of the @FieldToMatch@
--
-- __GT__: Used to test if the @Size@ is strictly greater than the size of
-- the @FieldToMatch@
sizeConstraint_comparisonOperator :: Lens.Lens' SizeConstraint ComparisonOperator
sizeConstraint_comparisonOperator :: (ComparisonOperator -> f ComparisonOperator)
-> SizeConstraint -> f SizeConstraint
sizeConstraint_comparisonOperator = (SizeConstraint -> ComparisonOperator)
-> (SizeConstraint -> ComparisonOperator -> SizeConstraint)
-> Lens
     SizeConstraint SizeConstraint ComparisonOperator ComparisonOperator
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SizeConstraint' {ComparisonOperator
comparisonOperator :: ComparisonOperator
$sel:comparisonOperator:SizeConstraint' :: SizeConstraint -> ComparisonOperator
comparisonOperator} -> ComparisonOperator
comparisonOperator) (\s :: SizeConstraint
s@SizeConstraint' {} ComparisonOperator
a -> SizeConstraint
s {$sel:comparisonOperator:SizeConstraint' :: ComparisonOperator
comparisonOperator = ComparisonOperator
a} :: SizeConstraint)

-- | The size in bytes that you want AWS WAF to compare against the size of
-- the specified @FieldToMatch@. AWS WAF uses this in combination with
-- @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.
--
-- Valid values for size are 0 - 21474836480 bytes (0 - 20 GB).
--
-- If you specify @URI@ for the value of @Type@, the \/ in the URI counts
-- as one character. For example, the URI @\/logo.jpg@ is nine characters
-- long.
sizeConstraint_size :: Lens.Lens' SizeConstraint Prelude.Natural
sizeConstraint_size :: (Natural -> f Natural) -> SizeConstraint -> f SizeConstraint
sizeConstraint_size = (SizeConstraint -> Natural)
-> (SizeConstraint -> Natural -> SizeConstraint)
-> Lens SizeConstraint SizeConstraint Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SizeConstraint' {Natural
size :: Natural
$sel:size:SizeConstraint' :: SizeConstraint -> Natural
size} -> Natural
size) (\s :: SizeConstraint
s@SizeConstraint' {} Natural
a -> SizeConstraint
s {$sel:size:SizeConstraint' :: Natural
size = Natural
a} :: SizeConstraint)

instance Core.FromJSON SizeConstraint where
  parseJSON :: Value -> Parser SizeConstraint
parseJSON =
    String
-> (Object -> Parser SizeConstraint)
-> Value
-> Parser SizeConstraint
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SizeConstraint"
      ( \Object
x ->
          FieldToMatch
-> TextTransformation
-> ComparisonOperator
-> Natural
-> SizeConstraint
SizeConstraint'
            (FieldToMatch
 -> TextTransformation
 -> ComparisonOperator
 -> Natural
 -> SizeConstraint)
-> Parser FieldToMatch
-> Parser
     (TextTransformation
      -> ComparisonOperator -> Natural -> SizeConstraint)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser FieldToMatch
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"FieldToMatch")
            Parser
  (TextTransformation
   -> ComparisonOperator -> Natural -> SizeConstraint)
-> Parser TextTransformation
-> Parser (ComparisonOperator -> Natural -> SizeConstraint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser TextTransformation
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TextTransformation")
            Parser (ComparisonOperator -> Natural -> SizeConstraint)
-> Parser ComparisonOperator -> Parser (Natural -> SizeConstraint)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ComparisonOperator
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ComparisonOperator")
            Parser (Natural -> SizeConstraint)
-> Parser Natural -> Parser SizeConstraint
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Size")
      )

instance Prelude.Hashable SizeConstraint

instance Prelude.NFData SizeConstraint

instance Core.ToJSON SizeConstraint where
  toJSON :: SizeConstraint -> Value
toJSON SizeConstraint' {Natural
ComparisonOperator
FieldToMatch
TextTransformation
size :: Natural
comparisonOperator :: ComparisonOperator
textTransformation :: TextTransformation
fieldToMatch :: FieldToMatch
$sel:size:SizeConstraint' :: SizeConstraint -> Natural
$sel:comparisonOperator:SizeConstraint' :: SizeConstraint -> ComparisonOperator
$sel:textTransformation:SizeConstraint' :: SizeConstraint -> TextTransformation
$sel:fieldToMatch:SizeConstraint' :: SizeConstraint -> FieldToMatch
..} =
    [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
"FieldToMatch" Text -> FieldToMatch -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FieldToMatch
fieldToMatch),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TextTransformation" Text -> TextTransformation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TextTransformation
textTransformation),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ComparisonOperator" Text -> ComparisonOperator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ComparisonOperator
comparisonOperator),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Size" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
size)
          ]
      )