{-# 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.FMS.ListResourceSets
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns an array of @ResourceSetSummary@ objects.
module Amazonka.FMS.ListResourceSets
  ( -- * Creating a Request
    ListResourceSets (..),
    newListResourceSets,

    -- * Request Lenses
    listResourceSets_maxResults,
    listResourceSets_nextToken,

    -- * Destructuring the Response
    ListResourceSetsResponse (..),
    newListResourceSetsResponse,

    -- * Response Lenses
    listResourceSetsResponse_nextToken,
    listResourceSetsResponse_resourceSets,
    listResourceSetsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListResourceSets' smart constructor.
data ListResourceSets = ListResourceSets'
  { -- | The maximum number of objects that you want Firewall Manager to return
    -- for this request. If more objects are available, in the response,
    -- Firewall Manager provides a @NextToken@ value that you can use in a
    -- subsequent call to get the next batch of objects.
    ListResourceSets -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | When you request a list of objects with a @MaxResults@ setting, if the
    -- number of objects that are still available for retrieval exceeds the
    -- maximum you requested, Firewall Manager returns a @NextToken@ value in
    -- the response. To retrieve the next batch of objects, use the token
    -- returned from the prior request in your next request.
    ListResourceSets -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListResourceSets -> ListResourceSets -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListResourceSets -> ListResourceSets -> Bool
$c/= :: ListResourceSets -> ListResourceSets -> Bool
== :: ListResourceSets -> ListResourceSets -> Bool
$c== :: ListResourceSets -> ListResourceSets -> Bool
Prelude.Eq, ReadPrec [ListResourceSets]
ReadPrec ListResourceSets
Int -> ReadS ListResourceSets
ReadS [ListResourceSets]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListResourceSets]
$creadListPrec :: ReadPrec [ListResourceSets]
readPrec :: ReadPrec ListResourceSets
$creadPrec :: ReadPrec ListResourceSets
readList :: ReadS [ListResourceSets]
$creadList :: ReadS [ListResourceSets]
readsPrec :: Int -> ReadS ListResourceSets
$creadsPrec :: Int -> ReadS ListResourceSets
Prelude.Read, Int -> ListResourceSets -> ShowS
[ListResourceSets] -> ShowS
ListResourceSets -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListResourceSets] -> ShowS
$cshowList :: [ListResourceSets] -> ShowS
show :: ListResourceSets -> String
$cshow :: ListResourceSets -> String
showsPrec :: Int -> ListResourceSets -> ShowS
$cshowsPrec :: Int -> ListResourceSets -> ShowS
Prelude.Show, forall x. Rep ListResourceSets x -> ListResourceSets
forall x. ListResourceSets -> Rep ListResourceSets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListResourceSets x -> ListResourceSets
$cfrom :: forall x. ListResourceSets -> Rep ListResourceSets x
Prelude.Generic)

-- |
-- Create a value of 'ListResourceSets' 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:
--
-- 'maxResults', 'listResourceSets_maxResults' - The maximum number of objects that you want Firewall Manager to return
-- for this request. If more objects are available, in the response,
-- Firewall Manager provides a @NextToken@ value that you can use in a
-- subsequent call to get the next batch of objects.
--
-- 'nextToken', 'listResourceSets_nextToken' - When you request a list of objects with a @MaxResults@ setting, if the
-- number of objects that are still available for retrieval exceeds the
-- maximum you requested, Firewall Manager returns a @NextToken@ value in
-- the response. To retrieve the next batch of objects, use the token
-- returned from the prior request in your next request.
newListResourceSets ::
  ListResourceSets
newListResourceSets :: ListResourceSets
newListResourceSets =
  ListResourceSets'
    { $sel:maxResults:ListResourceSets' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListResourceSets' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of objects that you want Firewall Manager to return
-- for this request. If more objects are available, in the response,
-- Firewall Manager provides a @NextToken@ value that you can use in a
-- subsequent call to get the next batch of objects.
listResourceSets_maxResults :: Lens.Lens' ListResourceSets (Prelude.Maybe Prelude.Natural)
listResourceSets_maxResults :: Lens' ListResourceSets (Maybe Natural)
listResourceSets_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourceSets' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListResourceSets' :: ListResourceSets -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListResourceSets
s@ListResourceSets' {} Maybe Natural
a -> ListResourceSets
s {$sel:maxResults:ListResourceSets' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListResourceSets)

-- | When you request a list of objects with a @MaxResults@ setting, if the
-- number of objects that are still available for retrieval exceeds the
-- maximum you requested, Firewall Manager returns a @NextToken@ value in
-- the response. To retrieve the next batch of objects, use the token
-- returned from the prior request in your next request.
listResourceSets_nextToken :: Lens.Lens' ListResourceSets (Prelude.Maybe Prelude.Text)
listResourceSets_nextToken :: Lens' ListResourceSets (Maybe Text)
listResourceSets_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourceSets' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListResourceSets' :: ListResourceSets -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListResourceSets
s@ListResourceSets' {} Maybe Text
a -> ListResourceSets
s {$sel:nextToken:ListResourceSets' :: Maybe Text
nextToken = Maybe Text
a} :: ListResourceSets)

instance Core.AWSRequest ListResourceSets where
  type
    AWSResponse ListResourceSets =
      ListResourceSetsResponse
  request :: (Service -> Service)
-> ListResourceSets -> Request ListResourceSets
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 ListResourceSets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListResourceSets)))
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 Text
-> Maybe [ResourceSetSummary] -> Int -> ListResourceSetsResponse
ListResourceSetsResponse'
            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
"NextToken")
            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
"ResourceSets" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListResourceSets where
  hashWithSalt :: Int -> ListResourceSets -> Int
hashWithSalt Int
_salt ListResourceSets' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListResourceSets' :: ListResourceSets -> Maybe Text
$sel:maxResults:ListResourceSets' :: ListResourceSets -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

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

instance Data.ToHeaders ListResourceSets where
  toHeaders :: ListResourceSets -> 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
"AWSFMS_20180101.ListResourceSets" ::
                          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 ListResourceSets where
  toJSON :: ListResourceSets -> Value
toJSON ListResourceSets' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListResourceSets' :: ListResourceSets -> Maybe Text
$sel:maxResults:ListResourceSets' :: ListResourceSets -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxResults" 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
maxResults,
            (Key
"NextToken" 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
nextToken
          ]
      )

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

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

-- | /See:/ 'newListResourceSetsResponse' smart constructor.
data ListResourceSetsResponse = ListResourceSetsResponse'
  { -- | When you request a list of objects with a @MaxResults@ setting, if the
    -- number of objects that are still available for retrieval exceeds the
    -- maximum you requested, Firewall Manager returns a @NextToken@ value in
    -- the response. To retrieve the next batch of objects, use the token
    -- returned from the prior request in your next request.
    ListResourceSetsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | An array of @ResourceSetSummary@ objects.
    ListResourceSetsResponse -> Maybe [ResourceSetSummary]
resourceSets :: Prelude.Maybe [ResourceSetSummary],
    -- | The response's http status code.
    ListResourceSetsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListResourceSetsResponse -> ListResourceSetsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListResourceSetsResponse -> ListResourceSetsResponse -> Bool
$c/= :: ListResourceSetsResponse -> ListResourceSetsResponse -> Bool
== :: ListResourceSetsResponse -> ListResourceSetsResponse -> Bool
$c== :: ListResourceSetsResponse -> ListResourceSetsResponse -> Bool
Prelude.Eq, ReadPrec [ListResourceSetsResponse]
ReadPrec ListResourceSetsResponse
Int -> ReadS ListResourceSetsResponse
ReadS [ListResourceSetsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListResourceSetsResponse]
$creadListPrec :: ReadPrec [ListResourceSetsResponse]
readPrec :: ReadPrec ListResourceSetsResponse
$creadPrec :: ReadPrec ListResourceSetsResponse
readList :: ReadS [ListResourceSetsResponse]
$creadList :: ReadS [ListResourceSetsResponse]
readsPrec :: Int -> ReadS ListResourceSetsResponse
$creadsPrec :: Int -> ReadS ListResourceSetsResponse
Prelude.Read, Int -> ListResourceSetsResponse -> ShowS
[ListResourceSetsResponse] -> ShowS
ListResourceSetsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListResourceSetsResponse] -> ShowS
$cshowList :: [ListResourceSetsResponse] -> ShowS
show :: ListResourceSetsResponse -> String
$cshow :: ListResourceSetsResponse -> String
showsPrec :: Int -> ListResourceSetsResponse -> ShowS
$cshowsPrec :: Int -> ListResourceSetsResponse -> ShowS
Prelude.Show, forall x.
Rep ListResourceSetsResponse x -> ListResourceSetsResponse
forall x.
ListResourceSetsResponse -> Rep ListResourceSetsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListResourceSetsResponse x -> ListResourceSetsResponse
$cfrom :: forall x.
ListResourceSetsResponse -> Rep ListResourceSetsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListResourceSetsResponse' 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:
--
-- 'nextToken', 'listResourceSetsResponse_nextToken' - When you request a list of objects with a @MaxResults@ setting, if the
-- number of objects that are still available for retrieval exceeds the
-- maximum you requested, Firewall Manager returns a @NextToken@ value in
-- the response. To retrieve the next batch of objects, use the token
-- returned from the prior request in your next request.
--
-- 'resourceSets', 'listResourceSetsResponse_resourceSets' - An array of @ResourceSetSummary@ objects.
--
-- 'httpStatus', 'listResourceSetsResponse_httpStatus' - The response's http status code.
newListResourceSetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListResourceSetsResponse
newListResourceSetsResponse :: Int -> ListResourceSetsResponse
newListResourceSetsResponse Int
pHttpStatus_ =
  ListResourceSetsResponse'
    { $sel:nextToken:ListResourceSetsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceSets:ListResourceSetsResponse' :: Maybe [ResourceSetSummary]
resourceSets = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListResourceSetsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | When you request a list of objects with a @MaxResults@ setting, if the
-- number of objects that are still available for retrieval exceeds the
-- maximum you requested, Firewall Manager returns a @NextToken@ value in
-- the response. To retrieve the next batch of objects, use the token
-- returned from the prior request in your next request.
listResourceSetsResponse_nextToken :: Lens.Lens' ListResourceSetsResponse (Prelude.Maybe Prelude.Text)
listResourceSetsResponse_nextToken :: Lens' ListResourceSetsResponse (Maybe Text)
listResourceSetsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourceSetsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListResourceSetsResponse' :: ListResourceSetsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListResourceSetsResponse
s@ListResourceSetsResponse' {} Maybe Text
a -> ListResourceSetsResponse
s {$sel:nextToken:ListResourceSetsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListResourceSetsResponse)

-- | An array of @ResourceSetSummary@ objects.
listResourceSetsResponse_resourceSets :: Lens.Lens' ListResourceSetsResponse (Prelude.Maybe [ResourceSetSummary])
listResourceSetsResponse_resourceSets :: Lens' ListResourceSetsResponse (Maybe [ResourceSetSummary])
listResourceSetsResponse_resourceSets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourceSetsResponse' {Maybe [ResourceSetSummary]
resourceSets :: Maybe [ResourceSetSummary]
$sel:resourceSets:ListResourceSetsResponse' :: ListResourceSetsResponse -> Maybe [ResourceSetSummary]
resourceSets} -> Maybe [ResourceSetSummary]
resourceSets) (\s :: ListResourceSetsResponse
s@ListResourceSetsResponse' {} Maybe [ResourceSetSummary]
a -> ListResourceSetsResponse
s {$sel:resourceSets:ListResourceSetsResponse' :: Maybe [ResourceSetSummary]
resourceSets = Maybe [ResourceSetSummary]
a} :: ListResourceSetsResponse) 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

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

instance Prelude.NFData ListResourceSetsResponse where
  rnf :: ListResourceSetsResponse -> ()
rnf ListResourceSetsResponse' {Int
Maybe [ResourceSetSummary]
Maybe Text
httpStatus :: Int
resourceSets :: Maybe [ResourceSetSummary]
nextToken :: Maybe Text
$sel:httpStatus:ListResourceSetsResponse' :: ListResourceSetsResponse -> Int
$sel:resourceSets:ListResourceSetsResponse' :: ListResourceSetsResponse -> Maybe [ResourceSetSummary]
$sel:nextToken:ListResourceSetsResponse' :: ListResourceSetsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ResourceSetSummary]
resourceSets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus