{-# 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.IPSetUpdate
-- 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.IPSetUpdate 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.IPSetDescriptor

-- | 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 IPSet with UpdateIPSet.
--
-- /See:/ 'newIPSetUpdate' smart constructor.
data IPSetUpdate = IPSetUpdate'
  { -- | Specifies whether to insert or delete an IP address with UpdateIPSet.
    IPSetUpdate -> ChangeAction
action :: ChangeAction,
    -- | The IP address type (@IPV4@ or @IPV6@) and the IP address range (in CIDR
    -- notation) that web requests originate from.
    IPSetUpdate -> IPSetDescriptor
iPSetDescriptor :: IPSetDescriptor
  }
  deriving (IPSetUpdate -> IPSetUpdate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IPSetUpdate -> IPSetUpdate -> Bool
$c/= :: IPSetUpdate -> IPSetUpdate -> Bool
== :: IPSetUpdate -> IPSetUpdate -> Bool
$c== :: IPSetUpdate -> IPSetUpdate -> Bool
Prelude.Eq, ReadPrec [IPSetUpdate]
ReadPrec IPSetUpdate
Int -> ReadS IPSetUpdate
ReadS [IPSetUpdate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IPSetUpdate]
$creadListPrec :: ReadPrec [IPSetUpdate]
readPrec :: ReadPrec IPSetUpdate
$creadPrec :: ReadPrec IPSetUpdate
readList :: ReadS [IPSetUpdate]
$creadList :: ReadS [IPSetUpdate]
readsPrec :: Int -> ReadS IPSetUpdate
$creadsPrec :: Int -> ReadS IPSetUpdate
Prelude.Read, Int -> IPSetUpdate -> ShowS
[IPSetUpdate] -> ShowS
IPSetUpdate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IPSetUpdate] -> ShowS
$cshowList :: [IPSetUpdate] -> ShowS
show :: IPSetUpdate -> String
$cshow :: IPSetUpdate -> String
showsPrec :: Int -> IPSetUpdate -> ShowS
$cshowsPrec :: Int -> IPSetUpdate -> ShowS
Prelude.Show, forall x. Rep IPSetUpdate x -> IPSetUpdate
forall x. IPSetUpdate -> Rep IPSetUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IPSetUpdate x -> IPSetUpdate
$cfrom :: forall x. IPSetUpdate -> Rep IPSetUpdate x
Prelude.Generic)

-- |
-- Create a value of 'IPSetUpdate' 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', 'iPSetUpdate_action' - Specifies whether to insert or delete an IP address with UpdateIPSet.
--
-- 'iPSetDescriptor', 'iPSetUpdate_iPSetDescriptor' - The IP address type (@IPV4@ or @IPV6@) and the IP address range (in CIDR
-- notation) that web requests originate from.
newIPSetUpdate ::
  -- | 'action'
  ChangeAction ->
  -- | 'iPSetDescriptor'
  IPSetDescriptor ->
  IPSetUpdate
newIPSetUpdate :: ChangeAction -> IPSetDescriptor -> IPSetUpdate
newIPSetUpdate ChangeAction
pAction_ IPSetDescriptor
pIPSetDescriptor_ =
  IPSetUpdate'
    { $sel:action:IPSetUpdate' :: ChangeAction
action = ChangeAction
pAction_,
      $sel:iPSetDescriptor:IPSetUpdate' :: IPSetDescriptor
iPSetDescriptor = IPSetDescriptor
pIPSetDescriptor_
    }

-- | Specifies whether to insert or delete an IP address with UpdateIPSet.
iPSetUpdate_action :: Lens.Lens' IPSetUpdate ChangeAction
iPSetUpdate_action :: Lens' IPSetUpdate ChangeAction
iPSetUpdate_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IPSetUpdate' {ChangeAction
action :: ChangeAction
$sel:action:IPSetUpdate' :: IPSetUpdate -> ChangeAction
action} -> ChangeAction
action) (\s :: IPSetUpdate
s@IPSetUpdate' {} ChangeAction
a -> IPSetUpdate
s {$sel:action:IPSetUpdate' :: ChangeAction
action = ChangeAction
a} :: IPSetUpdate)

-- | The IP address type (@IPV4@ or @IPV6@) and the IP address range (in CIDR
-- notation) that web requests originate from.
iPSetUpdate_iPSetDescriptor :: Lens.Lens' IPSetUpdate IPSetDescriptor
iPSetUpdate_iPSetDescriptor :: Lens' IPSetUpdate IPSetDescriptor
iPSetUpdate_iPSetDescriptor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IPSetUpdate' {IPSetDescriptor
iPSetDescriptor :: IPSetDescriptor
$sel:iPSetDescriptor:IPSetUpdate' :: IPSetUpdate -> IPSetDescriptor
iPSetDescriptor} -> IPSetDescriptor
iPSetDescriptor) (\s :: IPSetUpdate
s@IPSetUpdate' {} IPSetDescriptor
a -> IPSetUpdate
s {$sel:iPSetDescriptor:IPSetUpdate' :: IPSetDescriptor
iPSetDescriptor = IPSetDescriptor
a} :: IPSetUpdate)

instance Prelude.Hashable IPSetUpdate where
  hashWithSalt :: Int -> IPSetUpdate -> Int
hashWithSalt Int
_salt IPSetUpdate' {ChangeAction
IPSetDescriptor
iPSetDescriptor :: IPSetDescriptor
action :: ChangeAction
$sel:iPSetDescriptor:IPSetUpdate' :: IPSetUpdate -> IPSetDescriptor
$sel:action:IPSetUpdate' :: IPSetUpdate -> ChangeAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ChangeAction
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` IPSetDescriptor
iPSetDescriptor

instance Prelude.NFData IPSetUpdate where
  rnf :: IPSetUpdate -> ()
rnf IPSetUpdate' {ChangeAction
IPSetDescriptor
iPSetDescriptor :: IPSetDescriptor
action :: ChangeAction
$sel:iPSetDescriptor:IPSetUpdate' :: IPSetUpdate -> IPSetDescriptor
$sel:action:IPSetUpdate' :: IPSetUpdate -> 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 IPSetDescriptor
iPSetDescriptor

instance Data.ToJSON IPSetUpdate where
  toJSON :: IPSetUpdate -> Value
toJSON IPSetUpdate' {ChangeAction
IPSetDescriptor
iPSetDescriptor :: IPSetDescriptor
action :: ChangeAction
$sel:iPSetDescriptor:IPSetUpdate' :: IPSetUpdate -> IPSetDescriptor
$sel:action:IPSetUpdate' :: IPSetUpdate -> 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
"IPSetDescriptor" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= IPSetDescriptor
iPSetDescriptor)
          ]
      )