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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFRegional.Types.ChangeAction
import Amazonka.WAFRegional.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.
--
-- Specifies the type of update to perform to an GeoMatchSet with
-- UpdateGeoMatchSet.
--
-- /See:/ 'newGeoMatchSetUpdate' smart constructor.
data GeoMatchSetUpdate = GeoMatchSetUpdate'
  { -- | Specifies whether to insert or delete a country with UpdateGeoMatchSet.
    GeoMatchSetUpdate -> ChangeAction
action :: ChangeAction,
    -- | The country from which web requests originate that you want AWS WAF to
    -- search for.
    GeoMatchSetUpdate -> GeoMatchConstraint
geoMatchConstraint :: GeoMatchConstraint
  }
  deriving (GeoMatchSetUpdate -> GeoMatchSetUpdate -> Bool
(GeoMatchSetUpdate -> GeoMatchSetUpdate -> Bool)
-> (GeoMatchSetUpdate -> GeoMatchSetUpdate -> Bool)
-> Eq GeoMatchSetUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GeoMatchSetUpdate -> GeoMatchSetUpdate -> Bool
$c/= :: GeoMatchSetUpdate -> GeoMatchSetUpdate -> Bool
== :: GeoMatchSetUpdate -> GeoMatchSetUpdate -> Bool
$c== :: GeoMatchSetUpdate -> GeoMatchSetUpdate -> Bool
Prelude.Eq, ReadPrec [GeoMatchSetUpdate]
ReadPrec GeoMatchSetUpdate
Int -> ReadS GeoMatchSetUpdate
ReadS [GeoMatchSetUpdate]
(Int -> ReadS GeoMatchSetUpdate)
-> ReadS [GeoMatchSetUpdate]
-> ReadPrec GeoMatchSetUpdate
-> ReadPrec [GeoMatchSetUpdate]
-> Read GeoMatchSetUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GeoMatchSetUpdate]
$creadListPrec :: ReadPrec [GeoMatchSetUpdate]
readPrec :: ReadPrec GeoMatchSetUpdate
$creadPrec :: ReadPrec GeoMatchSetUpdate
readList :: ReadS [GeoMatchSetUpdate]
$creadList :: ReadS [GeoMatchSetUpdate]
readsPrec :: Int -> ReadS GeoMatchSetUpdate
$creadsPrec :: Int -> ReadS GeoMatchSetUpdate
Prelude.Read, Int -> GeoMatchSetUpdate -> ShowS
[GeoMatchSetUpdate] -> ShowS
GeoMatchSetUpdate -> String
(Int -> GeoMatchSetUpdate -> ShowS)
-> (GeoMatchSetUpdate -> String)
-> ([GeoMatchSetUpdate] -> ShowS)
-> Show GeoMatchSetUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GeoMatchSetUpdate] -> ShowS
$cshowList :: [GeoMatchSetUpdate] -> ShowS
show :: GeoMatchSetUpdate -> String
$cshow :: GeoMatchSetUpdate -> String
showsPrec :: Int -> GeoMatchSetUpdate -> ShowS
$cshowsPrec :: Int -> GeoMatchSetUpdate -> ShowS
Prelude.Show, (forall x. GeoMatchSetUpdate -> Rep GeoMatchSetUpdate x)
-> (forall x. Rep GeoMatchSetUpdate x -> GeoMatchSetUpdate)
-> Generic GeoMatchSetUpdate
forall x. Rep GeoMatchSetUpdate x -> GeoMatchSetUpdate
forall x. GeoMatchSetUpdate -> Rep GeoMatchSetUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GeoMatchSetUpdate x -> GeoMatchSetUpdate
$cfrom :: forall x. GeoMatchSetUpdate -> Rep GeoMatchSetUpdate x
Prelude.Generic)

-- |
-- Create a value of 'GeoMatchSetUpdate' 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', 'geoMatchSetUpdate_action' - Specifies whether to insert or delete a country with UpdateGeoMatchSet.
--
-- 'geoMatchConstraint', 'geoMatchSetUpdate_geoMatchConstraint' - The country from which web requests originate that you want AWS WAF to
-- search for.
newGeoMatchSetUpdate ::
  -- | 'action'
  ChangeAction ->
  -- | 'geoMatchConstraint'
  GeoMatchConstraint ->
  GeoMatchSetUpdate
newGeoMatchSetUpdate :: ChangeAction -> GeoMatchConstraint -> GeoMatchSetUpdate
newGeoMatchSetUpdate ChangeAction
pAction_ GeoMatchConstraint
pGeoMatchConstraint_ =
  GeoMatchSetUpdate' :: ChangeAction -> GeoMatchConstraint -> GeoMatchSetUpdate
GeoMatchSetUpdate'
    { $sel:action:GeoMatchSetUpdate' :: ChangeAction
action = ChangeAction
pAction_,
      $sel:geoMatchConstraint:GeoMatchSetUpdate' :: GeoMatchConstraint
geoMatchConstraint = GeoMatchConstraint
pGeoMatchConstraint_
    }

-- | Specifies whether to insert or delete a country with UpdateGeoMatchSet.
geoMatchSetUpdate_action :: Lens.Lens' GeoMatchSetUpdate ChangeAction
geoMatchSetUpdate_action :: (ChangeAction -> f ChangeAction)
-> GeoMatchSetUpdate -> f GeoMatchSetUpdate
geoMatchSetUpdate_action = (GeoMatchSetUpdate -> ChangeAction)
-> (GeoMatchSetUpdate -> ChangeAction -> GeoMatchSetUpdate)
-> Lens
     GeoMatchSetUpdate GeoMatchSetUpdate ChangeAction ChangeAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoMatchSetUpdate' {ChangeAction
action :: ChangeAction
$sel:action:GeoMatchSetUpdate' :: GeoMatchSetUpdate -> ChangeAction
action} -> ChangeAction
action) (\s :: GeoMatchSetUpdate
s@GeoMatchSetUpdate' {} ChangeAction
a -> GeoMatchSetUpdate
s {$sel:action:GeoMatchSetUpdate' :: ChangeAction
action = ChangeAction
a} :: GeoMatchSetUpdate)

-- | The country from which web requests originate that you want AWS WAF to
-- search for.
geoMatchSetUpdate_geoMatchConstraint :: Lens.Lens' GeoMatchSetUpdate GeoMatchConstraint
geoMatchSetUpdate_geoMatchConstraint :: (GeoMatchConstraint -> f GeoMatchConstraint)
-> GeoMatchSetUpdate -> f GeoMatchSetUpdate
geoMatchSetUpdate_geoMatchConstraint = (GeoMatchSetUpdate -> GeoMatchConstraint)
-> (GeoMatchSetUpdate -> GeoMatchConstraint -> GeoMatchSetUpdate)
-> Lens
     GeoMatchSetUpdate
     GeoMatchSetUpdate
     GeoMatchConstraint
     GeoMatchConstraint
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GeoMatchSetUpdate' {GeoMatchConstraint
geoMatchConstraint :: GeoMatchConstraint
$sel:geoMatchConstraint:GeoMatchSetUpdate' :: GeoMatchSetUpdate -> GeoMatchConstraint
geoMatchConstraint} -> GeoMatchConstraint
geoMatchConstraint) (\s :: GeoMatchSetUpdate
s@GeoMatchSetUpdate' {} GeoMatchConstraint
a -> GeoMatchSetUpdate
s {$sel:geoMatchConstraint:GeoMatchSetUpdate' :: GeoMatchConstraint
geoMatchConstraint = GeoMatchConstraint
a} :: GeoMatchSetUpdate)

instance Prelude.Hashable GeoMatchSetUpdate

instance Prelude.NFData GeoMatchSetUpdate

instance Core.ToJSON GeoMatchSetUpdate where
  toJSON :: GeoMatchSetUpdate -> Value
toJSON GeoMatchSetUpdate' {ChangeAction
GeoMatchConstraint
geoMatchConstraint :: GeoMatchConstraint
action :: ChangeAction
$sel:geoMatchConstraint:GeoMatchSetUpdate' :: GeoMatchSetUpdate -> GeoMatchConstraint
$sel:action:GeoMatchSetUpdate' :: GeoMatchSetUpdate -> 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
"GeoMatchConstraint" Text -> GeoMatchConstraint -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= GeoMatchConstraint
geoMatchConstraint)
          ]
      )