{-# 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.Route53RecoveryReadiness.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)
--
-- Lists the resource sets in an account.
--
-- This operation returns paginated results.
module Amazonka.Route53RecoveryReadiness.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 qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Route53RecoveryReadiness.Types

-- | /See:/ 'newListResourceSets' smart constructor.
data ListResourceSets = ListResourceSets'
  { -- | The number of objects that you want to return with this call.
    ListResourceSets -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token that identifies which batch of results you want to see.
    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 number of objects that you want to return with this call.
--
-- 'nextToken', 'listResourceSets_nextToken' - The token that identifies which batch of results you want to see.
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 number of objects that you want to return with this call.
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)

-- | The token that identifies which batch of results you want to see.
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.AWSPager ListResourceSets where
  page :: ListResourceSets
-> AWSResponse ListResourceSets -> Maybe ListResourceSets
page ListResourceSets
rq AWSResponse ListResourceSets
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListResourceSets
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListResourceSetsResponse (Maybe Text)
listResourceSetsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListResourceSets
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListResourceSetsResponse (Maybe [ResourceSetOutput])
listResourceSetsResponse_resourceSets
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListResourceSets
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListResourceSets (Maybe Text)
listResourceSets_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListResourceSets
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListResourceSetsResponse (Maybe Text)
listResourceSetsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListResourceSets where
  type
    AWSResponse ListResourceSets =
      ListResourceSetsResponse
  request :: (Service -> Service)
-> ListResourceSets -> Request ListResourceSets
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (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 [ResourceSetOutput] -> 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
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToQuery ListResourceSets where
  toQuery :: ListResourceSets -> QueryString
toQuery 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. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListResourceSetsResponse' smart constructor.
data ListResourceSetsResponse = ListResourceSetsResponse'
  { -- | The token that identifies which batch of results you want to see.
    ListResourceSetsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of resource sets associated with the account.
    ListResourceSetsResponse -> Maybe [ResourceSetOutput]
resourceSets :: Prelude.Maybe [ResourceSetOutput],
    -- | 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' - The token that identifies which batch of results you want to see.
--
-- 'resourceSets', 'listResourceSetsResponse_resourceSets' - A list of resource sets associated with the account.
--
-- '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 [ResourceSetOutput]
resourceSets = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListResourceSetsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token that identifies which batch of results you want to see.
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)

-- | A list of resource sets associated with the account.
listResourceSetsResponse_resourceSets :: Lens.Lens' ListResourceSetsResponse (Prelude.Maybe [ResourceSetOutput])
listResourceSetsResponse_resourceSets :: Lens' ListResourceSetsResponse (Maybe [ResourceSetOutput])
listResourceSetsResponse_resourceSets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListResourceSetsResponse' {Maybe [ResourceSetOutput]
resourceSets :: Maybe [ResourceSetOutput]
$sel:resourceSets:ListResourceSetsResponse' :: ListResourceSetsResponse -> Maybe [ResourceSetOutput]
resourceSets} -> Maybe [ResourceSetOutput]
resourceSets) (\s :: ListResourceSetsResponse
s@ListResourceSetsResponse' {} Maybe [ResourceSetOutput]
a -> ListResourceSetsResponse
s {$sel:resourceSets:ListResourceSetsResponse' :: Maybe [ResourceSetOutput]
resourceSets = Maybe [ResourceSetOutput]
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 [ResourceSetOutput]
Maybe Text
httpStatus :: Int
resourceSets :: Maybe [ResourceSetOutput]
nextToken :: Maybe Text
$sel:httpStatus:ListResourceSetsResponse' :: ListResourceSetsResponse -> Int
$sel:resourceSets:ListResourceSetsResponse' :: ListResourceSetsResponse -> Maybe [ResourceSetOutput]
$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 [ResourceSetOutput]
resourceSets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus