{-# 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-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.GeoMatchSetUpdate 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.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
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]
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
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. 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'
    { $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 :: Lens' GeoMatchSetUpdate ChangeAction
geoMatchSetUpdate_action = 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 :: Lens' GeoMatchSetUpdate GeoMatchConstraint
geoMatchSetUpdate_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 where
  hashWithSalt :: Int -> GeoMatchSetUpdate -> Int
hashWithSalt Int
_salt GeoMatchSetUpdate' {ChangeAction
GeoMatchConstraint
geoMatchConstraint :: GeoMatchConstraint
action :: ChangeAction
$sel:geoMatchConstraint:GeoMatchSetUpdate' :: GeoMatchSetUpdate -> GeoMatchConstraint
$sel:action:GeoMatchSetUpdate' :: GeoMatchSetUpdate -> ChangeAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ChangeAction
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GeoMatchConstraint
geoMatchConstraint

instance Prelude.NFData GeoMatchSetUpdate where
  rnf :: GeoMatchSetUpdate -> ()
rnf GeoMatchSetUpdate' {ChangeAction
GeoMatchConstraint
geoMatchConstraint :: GeoMatchConstraint
action :: ChangeAction
$sel:geoMatchConstraint:GeoMatchSetUpdate' :: GeoMatchSetUpdate -> GeoMatchConstraint
$sel:action:GeoMatchSetUpdate' :: GeoMatchSetUpdate -> ChangeAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ChangeAction
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf GeoMatchConstraint
geoMatchConstraint

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Action" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ChangeAction
action),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"GeoMatchConstraint" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= GeoMatchConstraint
geoMatchConstraint)
          ]
      )