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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAF.Types.GeoMatchConstraint

-- | 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.
--
-- Contains one or more countries that AWS WAF will search for.
--
-- /See:/ 'newGeoMatchSet' smart constructor.
data GeoMatchSet = GeoMatchSet'
  { -- | A friendly name or description of the GeoMatchSet. You can\'t change the
    -- name of an @GeoMatchSet@ after you create it.
    GeoMatchSet -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The @GeoMatchSetId@ for an @GeoMatchSet@. You use @GeoMatchSetId@ to get
    -- information about a @GeoMatchSet@ (see GeoMatchSet), update a
    -- @GeoMatchSet@ (see UpdateGeoMatchSet), insert a @GeoMatchSet@ into a
    -- @Rule@ or delete one from a @Rule@ (see UpdateRule), and delete a
    -- @GeoMatchSet@ from AWS WAF (see DeleteGeoMatchSet).
    --
    -- @GeoMatchSetId@ is returned by CreateGeoMatchSet and by
    -- ListGeoMatchSets.
    GeoMatchSet -> Text
geoMatchSetId :: Prelude.Text,
    -- | An array of GeoMatchConstraint objects, which contain the country that
    -- you want AWS WAF to search for.
    GeoMatchSet -> [GeoMatchConstraint]
geoMatchConstraints :: [GeoMatchConstraint]
  }
  deriving (GeoMatchSet -> GeoMatchSet -> Bool
(GeoMatchSet -> GeoMatchSet -> Bool)
-> (GeoMatchSet -> GeoMatchSet -> Bool) -> Eq GeoMatchSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GeoMatchSet -> GeoMatchSet -> Bool
$c/= :: GeoMatchSet -> GeoMatchSet -> Bool
== :: GeoMatchSet -> GeoMatchSet -> Bool
$c== :: GeoMatchSet -> GeoMatchSet -> Bool
Prelude.Eq, ReadPrec [GeoMatchSet]
ReadPrec GeoMatchSet
Int -> ReadS GeoMatchSet
ReadS [GeoMatchSet]
(Int -> ReadS GeoMatchSet)
-> ReadS [GeoMatchSet]
-> ReadPrec GeoMatchSet
-> ReadPrec [GeoMatchSet]
-> Read GeoMatchSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GeoMatchSet]
$creadListPrec :: ReadPrec [GeoMatchSet]
readPrec :: ReadPrec GeoMatchSet
$creadPrec :: ReadPrec GeoMatchSet
readList :: ReadS [GeoMatchSet]
$creadList :: ReadS [GeoMatchSet]
readsPrec :: Int -> ReadS GeoMatchSet
$creadsPrec :: Int -> ReadS GeoMatchSet
Prelude.Read, Int -> GeoMatchSet -> ShowS
[GeoMatchSet] -> ShowS
GeoMatchSet -> String
(Int -> GeoMatchSet -> ShowS)
-> (GeoMatchSet -> String)
-> ([GeoMatchSet] -> ShowS)
-> Show GeoMatchSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeoMatchSet] -> ShowS
$cshowList :: [GeoMatchSet] -> ShowS
show :: GeoMatchSet -> String
$cshow :: GeoMatchSet -> String
showsPrec :: Int -> GeoMatchSet -> ShowS
$cshowsPrec :: Int -> GeoMatchSet -> ShowS
Prelude.Show, (forall x. GeoMatchSet -> Rep GeoMatchSet x)
-> (forall x. Rep GeoMatchSet x -> GeoMatchSet)
-> Generic GeoMatchSet
forall x. Rep GeoMatchSet x -> GeoMatchSet
forall x. GeoMatchSet -> Rep GeoMatchSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GeoMatchSet x -> GeoMatchSet
$cfrom :: forall x. GeoMatchSet -> Rep GeoMatchSet x
Prelude.Generic)

-- |
-- Create a value of 'GeoMatchSet' 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', 'geoMatchSet_name' - A friendly name or description of the GeoMatchSet. You can\'t change the
-- name of an @GeoMatchSet@ after you create it.
--
-- 'geoMatchSetId', 'geoMatchSet_geoMatchSetId' - The @GeoMatchSetId@ for an @GeoMatchSet@. You use @GeoMatchSetId@ to get
-- information about a @GeoMatchSet@ (see GeoMatchSet), update a
-- @GeoMatchSet@ (see UpdateGeoMatchSet), insert a @GeoMatchSet@ into a
-- @Rule@ or delete one from a @Rule@ (see UpdateRule), and delete a
-- @GeoMatchSet@ from AWS WAF (see DeleteGeoMatchSet).
--
-- @GeoMatchSetId@ is returned by CreateGeoMatchSet and by
-- ListGeoMatchSets.
--
-- 'geoMatchConstraints', 'geoMatchSet_geoMatchConstraints' - An array of GeoMatchConstraint objects, which contain the country that
-- you want AWS WAF to search for.
newGeoMatchSet ::
  -- | 'geoMatchSetId'
  Prelude.Text ->
  GeoMatchSet
newGeoMatchSet :: Text -> GeoMatchSet
newGeoMatchSet Text
pGeoMatchSetId_ =
  GeoMatchSet' :: Maybe Text -> Text -> [GeoMatchConstraint] -> GeoMatchSet
GeoMatchSet'
    { $sel:name:GeoMatchSet' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:geoMatchSetId:GeoMatchSet' :: Text
geoMatchSetId = Text
pGeoMatchSetId_,
      $sel:geoMatchConstraints:GeoMatchSet' :: [GeoMatchConstraint]
geoMatchConstraints = [GeoMatchConstraint]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A friendly name or description of the GeoMatchSet. You can\'t change the
-- name of an @GeoMatchSet@ after you create it.
geoMatchSet_name :: Lens.Lens' GeoMatchSet (Prelude.Maybe Prelude.Text)
geoMatchSet_name :: (Maybe Text -> f (Maybe Text)) -> GeoMatchSet -> f GeoMatchSet
geoMatchSet_name = (GeoMatchSet -> Maybe Text)
-> (GeoMatchSet -> Maybe Text -> GeoMatchSet)
-> Lens GeoMatchSet GeoMatchSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoMatchSet' {Maybe Text
name :: Maybe Text
$sel:name:GeoMatchSet' :: GeoMatchSet -> Maybe Text
name} -> Maybe Text
name) (\s :: GeoMatchSet
s@GeoMatchSet' {} Maybe Text
a -> GeoMatchSet
s {$sel:name:GeoMatchSet' :: Maybe Text
name = Maybe Text
a} :: GeoMatchSet)

-- | The @GeoMatchSetId@ for an @GeoMatchSet@. You use @GeoMatchSetId@ to get
-- information about a @GeoMatchSet@ (see GeoMatchSet), update a
-- @GeoMatchSet@ (see UpdateGeoMatchSet), insert a @GeoMatchSet@ into a
-- @Rule@ or delete one from a @Rule@ (see UpdateRule), and delete a
-- @GeoMatchSet@ from AWS WAF (see DeleteGeoMatchSet).
--
-- @GeoMatchSetId@ is returned by CreateGeoMatchSet and by
-- ListGeoMatchSets.
geoMatchSet_geoMatchSetId :: Lens.Lens' GeoMatchSet Prelude.Text
geoMatchSet_geoMatchSetId :: (Text -> f Text) -> GeoMatchSet -> f GeoMatchSet
geoMatchSet_geoMatchSetId = (GeoMatchSet -> Text)
-> (GeoMatchSet -> Text -> GeoMatchSet)
-> Lens GeoMatchSet GeoMatchSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoMatchSet' {Text
geoMatchSetId :: Text
$sel:geoMatchSetId:GeoMatchSet' :: GeoMatchSet -> Text
geoMatchSetId} -> Text
geoMatchSetId) (\s :: GeoMatchSet
s@GeoMatchSet' {} Text
a -> GeoMatchSet
s {$sel:geoMatchSetId:GeoMatchSet' :: Text
geoMatchSetId = Text
a} :: GeoMatchSet)

-- | An array of GeoMatchConstraint objects, which contain the country that
-- you want AWS WAF to search for.
geoMatchSet_geoMatchConstraints :: Lens.Lens' GeoMatchSet [GeoMatchConstraint]
geoMatchSet_geoMatchConstraints :: ([GeoMatchConstraint] -> f [GeoMatchConstraint])
-> GeoMatchSet -> f GeoMatchSet
geoMatchSet_geoMatchConstraints = (GeoMatchSet -> [GeoMatchConstraint])
-> (GeoMatchSet -> [GeoMatchConstraint] -> GeoMatchSet)
-> Lens
     GeoMatchSet GeoMatchSet [GeoMatchConstraint] [GeoMatchConstraint]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoMatchSet' {[GeoMatchConstraint]
geoMatchConstraints :: [GeoMatchConstraint]
$sel:geoMatchConstraints:GeoMatchSet' :: GeoMatchSet -> [GeoMatchConstraint]
geoMatchConstraints} -> [GeoMatchConstraint]
geoMatchConstraints) (\s :: GeoMatchSet
s@GeoMatchSet' {} [GeoMatchConstraint]
a -> GeoMatchSet
s {$sel:geoMatchConstraints:GeoMatchSet' :: [GeoMatchConstraint]
geoMatchConstraints = [GeoMatchConstraint]
a} :: GeoMatchSet) (([GeoMatchConstraint] -> f [GeoMatchConstraint])
 -> GeoMatchSet -> f GeoMatchSet)
-> (([GeoMatchConstraint] -> f [GeoMatchConstraint])
    -> [GeoMatchConstraint] -> f [GeoMatchConstraint])
-> ([GeoMatchConstraint] -> f [GeoMatchConstraint])
-> GeoMatchSet
-> f GeoMatchSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([GeoMatchConstraint] -> f [GeoMatchConstraint])
-> [GeoMatchConstraint] -> f [GeoMatchConstraint]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable GeoMatchSet

instance Prelude.NFData GeoMatchSet