{-# 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.GeoMatchConstraint
-- 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.GeoMatchConstraint 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.GeoMatchConstraintType
import Amazonka.WAFRegional.Types.GeoMatchConstraintValue

-- | 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.
--
-- The country from which web requests originate that you want AWS WAF to
-- search for.
--
-- /See:/ 'newGeoMatchConstraint' smart constructor.
data GeoMatchConstraint = GeoMatchConstraint'
  { -- | The type of geographical area you want AWS WAF to search for. Currently
    -- @Country@ is the only valid value.
    GeoMatchConstraint -> GeoMatchConstraintType
type' :: GeoMatchConstraintType,
    -- | The country that you want AWS WAF to search for.
    GeoMatchConstraint -> GeoMatchConstraintValue
value :: GeoMatchConstraintValue
  }
  deriving (GeoMatchConstraint -> GeoMatchConstraint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GeoMatchConstraint -> GeoMatchConstraint -> Bool
$c/= :: GeoMatchConstraint -> GeoMatchConstraint -> Bool
== :: GeoMatchConstraint -> GeoMatchConstraint -> Bool
$c== :: GeoMatchConstraint -> GeoMatchConstraint -> Bool
Prelude.Eq, ReadPrec [GeoMatchConstraint]
ReadPrec GeoMatchConstraint
Int -> ReadS GeoMatchConstraint
ReadS [GeoMatchConstraint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GeoMatchConstraint]
$creadListPrec :: ReadPrec [GeoMatchConstraint]
readPrec :: ReadPrec GeoMatchConstraint
$creadPrec :: ReadPrec GeoMatchConstraint
readList :: ReadS [GeoMatchConstraint]
$creadList :: ReadS [GeoMatchConstraint]
readsPrec :: Int -> ReadS GeoMatchConstraint
$creadsPrec :: Int -> ReadS GeoMatchConstraint
Prelude.Read, Int -> GeoMatchConstraint -> ShowS
[GeoMatchConstraint] -> ShowS
GeoMatchConstraint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeoMatchConstraint] -> ShowS
$cshowList :: [GeoMatchConstraint] -> ShowS
show :: GeoMatchConstraint -> String
$cshow :: GeoMatchConstraint -> String
showsPrec :: Int -> GeoMatchConstraint -> ShowS
$cshowsPrec :: Int -> GeoMatchConstraint -> ShowS
Prelude.Show, forall x. Rep GeoMatchConstraint x -> GeoMatchConstraint
forall x. GeoMatchConstraint -> Rep GeoMatchConstraint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GeoMatchConstraint x -> GeoMatchConstraint
$cfrom :: forall x. GeoMatchConstraint -> Rep GeoMatchConstraint x
Prelude.Generic)

-- |
-- Create a value of 'GeoMatchConstraint' 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:
--
-- 'type'', 'geoMatchConstraint_type' - The type of geographical area you want AWS WAF to search for. Currently
-- @Country@ is the only valid value.
--
-- 'value', 'geoMatchConstraint_value' - The country that you want AWS WAF to search for.
newGeoMatchConstraint ::
  -- | 'type''
  GeoMatchConstraintType ->
  -- | 'value'
  GeoMatchConstraintValue ->
  GeoMatchConstraint
newGeoMatchConstraint :: GeoMatchConstraintType
-> GeoMatchConstraintValue -> GeoMatchConstraint
newGeoMatchConstraint GeoMatchConstraintType
pType_ GeoMatchConstraintValue
pValue_ =
  GeoMatchConstraint'
    { $sel:type':GeoMatchConstraint' :: GeoMatchConstraintType
type' = GeoMatchConstraintType
pType_,
      $sel:value:GeoMatchConstraint' :: GeoMatchConstraintValue
value = GeoMatchConstraintValue
pValue_
    }

-- | The type of geographical area you want AWS WAF to search for. Currently
-- @Country@ is the only valid value.
geoMatchConstraint_type :: Lens.Lens' GeoMatchConstraint GeoMatchConstraintType
geoMatchConstraint_type :: Lens' GeoMatchConstraint GeoMatchConstraintType
geoMatchConstraint_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoMatchConstraint' {GeoMatchConstraintType
type' :: GeoMatchConstraintType
$sel:type':GeoMatchConstraint' :: GeoMatchConstraint -> GeoMatchConstraintType
type'} -> GeoMatchConstraintType
type') (\s :: GeoMatchConstraint
s@GeoMatchConstraint' {} GeoMatchConstraintType
a -> GeoMatchConstraint
s {$sel:type':GeoMatchConstraint' :: GeoMatchConstraintType
type' = GeoMatchConstraintType
a} :: GeoMatchConstraint)

-- | The country that you want AWS WAF to search for.
geoMatchConstraint_value :: Lens.Lens' GeoMatchConstraint GeoMatchConstraintValue
geoMatchConstraint_value :: Lens' GeoMatchConstraint GeoMatchConstraintValue
geoMatchConstraint_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoMatchConstraint' {GeoMatchConstraintValue
value :: GeoMatchConstraintValue
$sel:value:GeoMatchConstraint' :: GeoMatchConstraint -> GeoMatchConstraintValue
value} -> GeoMatchConstraintValue
value) (\s :: GeoMatchConstraint
s@GeoMatchConstraint' {} GeoMatchConstraintValue
a -> GeoMatchConstraint
s {$sel:value:GeoMatchConstraint' :: GeoMatchConstraintValue
value = GeoMatchConstraintValue
a} :: GeoMatchConstraint)

instance Data.FromJSON GeoMatchConstraint where
  parseJSON :: Value -> Parser GeoMatchConstraint
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GeoMatchConstraint"
      ( \Object
x ->
          GeoMatchConstraintType
-> GeoMatchConstraintValue -> GeoMatchConstraint
GeoMatchConstraint'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Value")
      )

instance Prelude.Hashable GeoMatchConstraint where
  hashWithSalt :: Int -> GeoMatchConstraint -> Int
hashWithSalt Int
_salt GeoMatchConstraint' {GeoMatchConstraintType
GeoMatchConstraintValue
value :: GeoMatchConstraintValue
type' :: GeoMatchConstraintType
$sel:value:GeoMatchConstraint' :: GeoMatchConstraint -> GeoMatchConstraintValue
$sel:type':GeoMatchConstraint' :: GeoMatchConstraint -> GeoMatchConstraintType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GeoMatchConstraintType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GeoMatchConstraintValue
value

instance Prelude.NFData GeoMatchConstraint where
  rnf :: GeoMatchConstraint -> ()
rnf GeoMatchConstraint' {GeoMatchConstraintType
GeoMatchConstraintValue
value :: GeoMatchConstraintValue
type' :: GeoMatchConstraintType
$sel:value:GeoMatchConstraint' :: GeoMatchConstraint -> GeoMatchConstraintValue
$sel:type':GeoMatchConstraint' :: GeoMatchConstraint -> GeoMatchConstraintType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf GeoMatchConstraintType
type' seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf GeoMatchConstraintValue
value

instance Data.ToJSON GeoMatchConstraint where
  toJSON :: GeoMatchConstraint -> Value
toJSON GeoMatchConstraint' {GeoMatchConstraintType
GeoMatchConstraintValue
value :: GeoMatchConstraintValue
type' :: GeoMatchConstraintType
$sel:value:GeoMatchConstraint' :: GeoMatchConstraint -> GeoMatchConstraintValue
$sel:type':GeoMatchConstraint' :: GeoMatchConstraint -> GeoMatchConstraintType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= GeoMatchConstraintType
type'),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= GeoMatchConstraintValue
value)
          ]
      )