{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.ListIPSets
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- 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.
--
-- Returns an array of IPSetSummary objects in the response.
module Amazonka.WAFRegional.ListIPSets
  ( -- * Creating a Request
    ListIPSets (..),
    newListIPSets,

    -- * Request Lenses
    listIPSets_limit,
    listIPSets_nextMarker,

    -- * Destructuring the Response
    ListIPSetsResponse (..),
    newListIPSetsResponse,

    -- * Response Lenses
    listIPSetsResponse_iPSets,
    listIPSetsResponse_nextMarker,
    listIPSetsResponse_httpStatus,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WAFRegional.Types

-- | /See:/ 'newListIPSets' smart constructor.
data ListIPSets = ListIPSets'
  { -- | Specifies the number of @IPSet@ objects that you want AWS WAF to return
    -- for this request. If you have more @IPSet@ objects than the number you
    -- specify for @Limit@, the response includes a @NextMarker@ value that you
    -- can use to get another batch of @IPSet@ objects.
    ListIPSets -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | AWS WAF returns a @NextMarker@ value in the response that allows you to
    -- list another group of @IPSets@. For the second and subsequent
    -- @ListIPSets@ requests, specify the value of @NextMarker@ from the
    -- previous response to get information about another batch of @IPSets@.
    ListIPSets -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text
  }
  deriving (ListIPSets -> ListIPSets -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIPSets -> ListIPSets -> Bool
$c/= :: ListIPSets -> ListIPSets -> Bool
== :: ListIPSets -> ListIPSets -> Bool
$c== :: ListIPSets -> ListIPSets -> Bool
Prelude.Eq, ReadPrec [ListIPSets]
ReadPrec ListIPSets
Int -> ReadS ListIPSets
ReadS [ListIPSets]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListIPSets]
$creadListPrec :: ReadPrec [ListIPSets]
readPrec :: ReadPrec ListIPSets
$creadPrec :: ReadPrec ListIPSets
readList :: ReadS [ListIPSets]
$creadList :: ReadS [ListIPSets]
readsPrec :: Int -> ReadS ListIPSets
$creadsPrec :: Int -> ReadS ListIPSets
Prelude.Read, Int -> ListIPSets -> ShowS
[ListIPSets] -> ShowS
ListIPSets -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIPSets] -> ShowS
$cshowList :: [ListIPSets] -> ShowS
show :: ListIPSets -> String
$cshow :: ListIPSets -> String
showsPrec :: Int -> ListIPSets -> ShowS
$cshowsPrec :: Int -> ListIPSets -> ShowS
Prelude.Show, forall x. Rep ListIPSets x -> ListIPSets
forall x. ListIPSets -> Rep ListIPSets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListIPSets x -> ListIPSets
$cfrom :: forall x. ListIPSets -> Rep ListIPSets x
Prelude.Generic)

-- |
-- Create a value of 'ListIPSets' 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:
--
-- 'limit', 'listIPSets_limit' - Specifies the number of @IPSet@ objects that you want AWS WAF to return
-- for this request. If you have more @IPSet@ objects than the number you
-- specify for @Limit@, the response includes a @NextMarker@ value that you
-- can use to get another batch of @IPSet@ objects.
--
-- 'nextMarker', 'listIPSets_nextMarker' - AWS WAF returns a @NextMarker@ value in the response that allows you to
-- list another group of @IPSets@. For the second and subsequent
-- @ListIPSets@ requests, specify the value of @NextMarker@ from the
-- previous response to get information about another batch of @IPSets@.
newListIPSets ::
  ListIPSets
newListIPSets :: ListIPSets
newListIPSets =
  ListIPSets'
    { $sel:limit:ListIPSets' :: Maybe Natural
limit = forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:ListIPSets' :: Maybe Text
nextMarker = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the number of @IPSet@ objects that you want AWS WAF to return
-- for this request. If you have more @IPSet@ objects than the number you
-- specify for @Limit@, the response includes a @NextMarker@ value that you
-- can use to get another batch of @IPSet@ objects.
listIPSets_limit :: Lens.Lens' ListIPSets (Prelude.Maybe Prelude.Natural)
listIPSets_limit :: Lens' ListIPSets (Maybe Natural)
listIPSets_limit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIPSets' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListIPSets' :: ListIPSets -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListIPSets
s@ListIPSets' {} Maybe Natural
a -> ListIPSets
s {$sel:limit:ListIPSets' :: Maybe Natural
limit = Maybe Natural
a} :: ListIPSets)

-- | AWS WAF returns a @NextMarker@ value in the response that allows you to
-- list another group of @IPSets@. For the second and subsequent
-- @ListIPSets@ requests, specify the value of @NextMarker@ from the
-- previous response to get information about another batch of @IPSets@.
listIPSets_nextMarker :: Lens.Lens' ListIPSets (Prelude.Maybe Prelude.Text)
listIPSets_nextMarker :: Lens' ListIPSets (Maybe Text)
listIPSets_nextMarker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIPSets' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:ListIPSets' :: ListIPSets -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: ListIPSets
s@ListIPSets' {} Maybe Text
a -> ListIPSets
s {$sel:nextMarker:ListIPSets' :: Maybe Text
nextMarker = Maybe Text
a} :: ListIPSets)

instance Core.AWSRequest ListIPSets where
  type AWSResponse ListIPSets = ListIPSetsResponse
  request :: (Service -> Service) -> ListIPSets -> Request ListIPSets
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListIPSets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListIPSets)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [IPSetSummary] -> Maybe Text -> Int -> ListIPSetsResponse
ListIPSetsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"IPSets" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextMarker")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListIPSets where
  hashWithSalt :: Int -> ListIPSets -> Int
hashWithSalt Int
_salt ListIPSets' {Maybe Natural
Maybe Text
nextMarker :: Maybe Text
limit :: Maybe Natural
$sel:nextMarker:ListIPSets' :: ListIPSets -> Maybe Text
$sel:limit:ListIPSets' :: ListIPSets -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
limit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextMarker

instance Prelude.NFData ListIPSets where
  rnf :: ListIPSets -> ()
rnf ListIPSets' {Maybe Natural
Maybe Text
nextMarker :: Maybe Text
limit :: Maybe Natural
$sel:nextMarker:ListIPSets' :: ListIPSets -> Maybe Text
$sel:limit:ListIPSets' :: ListIPSets -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
limit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextMarker

instance Data.ToHeaders ListIPSets where
  toHeaders :: ListIPSets -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSWAF_Regional_20161128.ListIPSets" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ListIPSets where
  toJSON :: ListIPSets -> Value
toJSON ListIPSets' {Maybe Natural
Maybe Text
nextMarker :: Maybe Text
limit :: Maybe Natural
$sel:nextMarker:ListIPSets' :: ListIPSets -> Maybe Text
$sel:limit:ListIPSets' :: ListIPSets -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Limit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            (Key
"NextMarker" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextMarker
          ]
      )

instance Data.ToPath ListIPSets where
  toPath :: ListIPSets -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery ListIPSets where
  toQuery :: ListIPSets -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListIPSetsResponse' smart constructor.
data ListIPSetsResponse = ListIPSetsResponse'
  { -- | An array of IPSetSummary objects.
    ListIPSetsResponse -> Maybe [IPSetSummary]
iPSets :: Prelude.Maybe [IPSetSummary],
    -- | To list more @IPSet@ objects, submit another @ListIPSets@ request, and
    -- in the next request use the @NextMarker@ response value as the
    -- @NextMarker@ value.
    ListIPSetsResponse -> Maybe Text
nextMarker :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListIPSetsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListIPSetsResponse -> ListIPSetsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIPSetsResponse -> ListIPSetsResponse -> Bool
$c/= :: ListIPSetsResponse -> ListIPSetsResponse -> Bool
== :: ListIPSetsResponse -> ListIPSetsResponse -> Bool
$c== :: ListIPSetsResponse -> ListIPSetsResponse -> Bool
Prelude.Eq, ReadPrec [ListIPSetsResponse]
ReadPrec ListIPSetsResponse
Int -> ReadS ListIPSetsResponse
ReadS [ListIPSetsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListIPSetsResponse]
$creadListPrec :: ReadPrec [ListIPSetsResponse]
readPrec :: ReadPrec ListIPSetsResponse
$creadPrec :: ReadPrec ListIPSetsResponse
readList :: ReadS [ListIPSetsResponse]
$creadList :: ReadS [ListIPSetsResponse]
readsPrec :: Int -> ReadS ListIPSetsResponse
$creadsPrec :: Int -> ReadS ListIPSetsResponse
Prelude.Read, Int -> ListIPSetsResponse -> ShowS
[ListIPSetsResponse] -> ShowS
ListIPSetsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIPSetsResponse] -> ShowS
$cshowList :: [ListIPSetsResponse] -> ShowS
show :: ListIPSetsResponse -> String
$cshow :: ListIPSetsResponse -> String
showsPrec :: Int -> ListIPSetsResponse -> ShowS
$cshowsPrec :: Int -> ListIPSetsResponse -> ShowS
Prelude.Show, forall x. Rep ListIPSetsResponse x -> ListIPSetsResponse
forall x. ListIPSetsResponse -> Rep ListIPSetsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListIPSetsResponse x -> ListIPSetsResponse
$cfrom :: forall x. ListIPSetsResponse -> Rep ListIPSetsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListIPSetsResponse' 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:
--
-- 'iPSets', 'listIPSetsResponse_iPSets' - An array of IPSetSummary objects.
--
-- 'nextMarker', 'listIPSetsResponse_nextMarker' - To list more @IPSet@ objects, submit another @ListIPSets@ request, and
-- in the next request use the @NextMarker@ response value as the
-- @NextMarker@ value.
--
-- 'httpStatus', 'listIPSetsResponse_httpStatus' - The response's http status code.
newListIPSetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListIPSetsResponse
newListIPSetsResponse :: Int -> ListIPSetsResponse
newListIPSetsResponse Int
pHttpStatus_ =
  ListIPSetsResponse'
    { $sel:iPSets:ListIPSetsResponse' :: Maybe [IPSetSummary]
iPSets = forall a. Maybe a
Prelude.Nothing,
      $sel:nextMarker:ListIPSetsResponse' :: Maybe Text
nextMarker = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListIPSetsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of IPSetSummary objects.
listIPSetsResponse_iPSets :: Lens.Lens' ListIPSetsResponse (Prelude.Maybe [IPSetSummary])
listIPSetsResponse_iPSets :: Lens' ListIPSetsResponse (Maybe [IPSetSummary])
listIPSetsResponse_iPSets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIPSetsResponse' {Maybe [IPSetSummary]
iPSets :: Maybe [IPSetSummary]
$sel:iPSets:ListIPSetsResponse' :: ListIPSetsResponse -> Maybe [IPSetSummary]
iPSets} -> Maybe [IPSetSummary]
iPSets) (\s :: ListIPSetsResponse
s@ListIPSetsResponse' {} Maybe [IPSetSummary]
a -> ListIPSetsResponse
s {$sel:iPSets:ListIPSetsResponse' :: Maybe [IPSetSummary]
iPSets = Maybe [IPSetSummary]
a} :: ListIPSetsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | To list more @IPSet@ objects, submit another @ListIPSets@ request, and
-- in the next request use the @NextMarker@ response value as the
-- @NextMarker@ value.
listIPSetsResponse_nextMarker :: Lens.Lens' ListIPSetsResponse (Prelude.Maybe Prelude.Text)
listIPSetsResponse_nextMarker :: Lens' ListIPSetsResponse (Maybe Text)
listIPSetsResponse_nextMarker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIPSetsResponse' {Maybe Text
nextMarker :: Maybe Text
$sel:nextMarker:ListIPSetsResponse' :: ListIPSetsResponse -> Maybe Text
nextMarker} -> Maybe Text
nextMarker) (\s :: ListIPSetsResponse
s@ListIPSetsResponse' {} Maybe Text
a -> ListIPSetsResponse
s {$sel:nextMarker:ListIPSetsResponse' :: Maybe Text
nextMarker = Maybe Text
a} :: ListIPSetsResponse)

-- | The response's http status code.
listIPSetsResponse_httpStatus :: Lens.Lens' ListIPSetsResponse Prelude.Int
listIPSetsResponse_httpStatus :: Lens' ListIPSetsResponse Int
listIPSetsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIPSetsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListIPSetsResponse' :: ListIPSetsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListIPSetsResponse
s@ListIPSetsResponse' {} Int
a -> ListIPSetsResponse
s {$sel:httpStatus:ListIPSetsResponse' :: Int
httpStatus = Int
a} :: ListIPSetsResponse)

instance Prelude.NFData ListIPSetsResponse where
  rnf :: ListIPSetsResponse -> ()
rnf ListIPSetsResponse' {Int
Maybe [IPSetSummary]
Maybe Text
httpStatus :: Int
nextMarker :: Maybe Text
iPSets :: Maybe [IPSetSummary]
$sel:httpStatus:ListIPSetsResponse' :: ListIPSetsResponse -> Int
$sel:nextMarker:ListIPSetsResponse' :: ListIPSetsResponse -> Maybe Text
$sel:iPSets:ListIPSetsResponse' :: ListIPSetsResponse -> Maybe [IPSetSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [IPSetSummary]
iPSets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextMarker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus