{-# 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.ListRecoveryGroups
-- 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 recovery groups in an account.
--
-- This operation returns paginated results.
module Amazonka.Route53RecoveryReadiness.ListRecoveryGroups
  ( -- * Creating a Request
    ListRecoveryGroups (..),
    newListRecoveryGroups,

    -- * Request Lenses
    listRecoveryGroups_maxResults,
    listRecoveryGroups_nextToken,

    -- * Destructuring the Response
    ListRecoveryGroupsResponse (..),
    newListRecoveryGroupsResponse,

    -- * Response Lenses
    listRecoveryGroupsResponse_nextToken,
    listRecoveryGroupsResponse_recoveryGroups,
    listRecoveryGroupsResponse_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:/ 'newListRecoveryGroups' smart constructor.
data ListRecoveryGroups = ListRecoveryGroups'
  { -- | The number of objects that you want to return with this call.
    ListRecoveryGroups -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token that identifies which batch of results you want to see.
    ListRecoveryGroups -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListRecoveryGroups -> ListRecoveryGroups -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRecoveryGroups -> ListRecoveryGroups -> Bool
$c/= :: ListRecoveryGroups -> ListRecoveryGroups -> Bool
== :: ListRecoveryGroups -> ListRecoveryGroups -> Bool
$c== :: ListRecoveryGroups -> ListRecoveryGroups -> Bool
Prelude.Eq, ReadPrec [ListRecoveryGroups]
ReadPrec ListRecoveryGroups
Int -> ReadS ListRecoveryGroups
ReadS [ListRecoveryGroups]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRecoveryGroups]
$creadListPrec :: ReadPrec [ListRecoveryGroups]
readPrec :: ReadPrec ListRecoveryGroups
$creadPrec :: ReadPrec ListRecoveryGroups
readList :: ReadS [ListRecoveryGroups]
$creadList :: ReadS [ListRecoveryGroups]
readsPrec :: Int -> ReadS ListRecoveryGroups
$creadsPrec :: Int -> ReadS ListRecoveryGroups
Prelude.Read, Int -> ListRecoveryGroups -> ShowS
[ListRecoveryGroups] -> ShowS
ListRecoveryGroups -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRecoveryGroups] -> ShowS
$cshowList :: [ListRecoveryGroups] -> ShowS
show :: ListRecoveryGroups -> String
$cshow :: ListRecoveryGroups -> String
showsPrec :: Int -> ListRecoveryGroups -> ShowS
$cshowsPrec :: Int -> ListRecoveryGroups -> ShowS
Prelude.Show, forall x. Rep ListRecoveryGroups x -> ListRecoveryGroups
forall x. ListRecoveryGroups -> Rep ListRecoveryGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListRecoveryGroups x -> ListRecoveryGroups
$cfrom :: forall x. ListRecoveryGroups -> Rep ListRecoveryGroups x
Prelude.Generic)

-- |
-- Create a value of 'ListRecoveryGroups' 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', 'listRecoveryGroups_maxResults' - The number of objects that you want to return with this call.
--
-- 'nextToken', 'listRecoveryGroups_nextToken' - The token that identifies which batch of results you want to see.
newListRecoveryGroups ::
  ListRecoveryGroups
newListRecoveryGroups :: ListRecoveryGroups
newListRecoveryGroups =
  ListRecoveryGroups'
    { $sel:maxResults:ListRecoveryGroups' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListRecoveryGroups' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of objects that you want to return with this call.
listRecoveryGroups_maxResults :: Lens.Lens' ListRecoveryGroups (Prelude.Maybe Prelude.Natural)
listRecoveryGroups_maxResults :: Lens' ListRecoveryGroups (Maybe Natural)
listRecoveryGroups_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecoveryGroups' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListRecoveryGroups' :: ListRecoveryGroups -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListRecoveryGroups
s@ListRecoveryGroups' {} Maybe Natural
a -> ListRecoveryGroups
s {$sel:maxResults:ListRecoveryGroups' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListRecoveryGroups)

-- | The token that identifies which batch of results you want to see.
listRecoveryGroups_nextToken :: Lens.Lens' ListRecoveryGroups (Prelude.Maybe Prelude.Text)
listRecoveryGroups_nextToken :: Lens' ListRecoveryGroups (Maybe Text)
listRecoveryGroups_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecoveryGroups' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRecoveryGroups' :: ListRecoveryGroups -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRecoveryGroups
s@ListRecoveryGroups' {} Maybe Text
a -> ListRecoveryGroups
s {$sel:nextToken:ListRecoveryGroups' :: Maybe Text
nextToken = Maybe Text
a} :: ListRecoveryGroups)

instance Core.AWSPager ListRecoveryGroups where
  page :: ListRecoveryGroups
-> AWSResponse ListRecoveryGroups -> Maybe ListRecoveryGroups
page ListRecoveryGroups
rq AWSResponse ListRecoveryGroups
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListRecoveryGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRecoveryGroupsResponse (Maybe Text)
listRecoveryGroupsResponse_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 ListRecoveryGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRecoveryGroupsResponse (Maybe [RecoveryGroupOutput])
listRecoveryGroupsResponse_recoveryGroups
            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.$ ListRecoveryGroups
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListRecoveryGroups (Maybe Text)
listRecoveryGroups_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListRecoveryGroups
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRecoveryGroupsResponse (Maybe Text)
listRecoveryGroupsResponse_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 ListRecoveryGroups where
  type
    AWSResponse ListRecoveryGroups =
      ListRecoveryGroupsResponse
  request :: (Service -> Service)
-> ListRecoveryGroups -> Request ListRecoveryGroups
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 ListRecoveryGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListRecoveryGroups)))
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 [RecoveryGroupOutput] -> Int -> ListRecoveryGroupsResponse
ListRecoveryGroupsResponse'
            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
"recoveryGroups" 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 ListRecoveryGroups where
  hashWithSalt :: Int -> ListRecoveryGroups -> Int
hashWithSalt Int
_salt ListRecoveryGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListRecoveryGroups' :: ListRecoveryGroups -> Maybe Text
$sel:maxResults:ListRecoveryGroups' :: ListRecoveryGroups -> 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 ListRecoveryGroups where
  rnf :: ListRecoveryGroups -> ()
rnf ListRecoveryGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListRecoveryGroups' :: ListRecoveryGroups -> Maybe Text
$sel:maxResults:ListRecoveryGroups' :: ListRecoveryGroups -> 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 ListRecoveryGroups where
  toHeaders :: ListRecoveryGroups -> 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 ListRecoveryGroups where
  toPath :: ListRecoveryGroups -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/recoverygroups"

instance Data.ToQuery ListRecoveryGroups where
  toQuery :: ListRecoveryGroups -> QueryString
toQuery ListRecoveryGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListRecoveryGroups' :: ListRecoveryGroups -> Maybe Text
$sel:maxResults:ListRecoveryGroups' :: ListRecoveryGroups -> 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:/ 'newListRecoveryGroupsResponse' smart constructor.
data ListRecoveryGroupsResponse = ListRecoveryGroupsResponse'
  { -- | The token that identifies which batch of results you want to see.
    ListRecoveryGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of recovery groups.
    ListRecoveryGroupsResponse -> Maybe [RecoveryGroupOutput]
recoveryGroups :: Prelude.Maybe [RecoveryGroupOutput],
    -- | The response's http status code.
    ListRecoveryGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListRecoveryGroupsResponse -> ListRecoveryGroupsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRecoveryGroupsResponse -> ListRecoveryGroupsResponse -> Bool
$c/= :: ListRecoveryGroupsResponse -> ListRecoveryGroupsResponse -> Bool
== :: ListRecoveryGroupsResponse -> ListRecoveryGroupsResponse -> Bool
$c== :: ListRecoveryGroupsResponse -> ListRecoveryGroupsResponse -> Bool
Prelude.Eq, ReadPrec [ListRecoveryGroupsResponse]
ReadPrec ListRecoveryGroupsResponse
Int -> ReadS ListRecoveryGroupsResponse
ReadS [ListRecoveryGroupsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRecoveryGroupsResponse]
$creadListPrec :: ReadPrec [ListRecoveryGroupsResponse]
readPrec :: ReadPrec ListRecoveryGroupsResponse
$creadPrec :: ReadPrec ListRecoveryGroupsResponse
readList :: ReadS [ListRecoveryGroupsResponse]
$creadList :: ReadS [ListRecoveryGroupsResponse]
readsPrec :: Int -> ReadS ListRecoveryGroupsResponse
$creadsPrec :: Int -> ReadS ListRecoveryGroupsResponse
Prelude.Read, Int -> ListRecoveryGroupsResponse -> ShowS
[ListRecoveryGroupsResponse] -> ShowS
ListRecoveryGroupsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRecoveryGroupsResponse] -> ShowS
$cshowList :: [ListRecoveryGroupsResponse] -> ShowS
show :: ListRecoveryGroupsResponse -> String
$cshow :: ListRecoveryGroupsResponse -> String
showsPrec :: Int -> ListRecoveryGroupsResponse -> ShowS
$cshowsPrec :: Int -> ListRecoveryGroupsResponse -> ShowS
Prelude.Show, forall x.
Rep ListRecoveryGroupsResponse x -> ListRecoveryGroupsResponse
forall x.
ListRecoveryGroupsResponse -> Rep ListRecoveryGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListRecoveryGroupsResponse x -> ListRecoveryGroupsResponse
$cfrom :: forall x.
ListRecoveryGroupsResponse -> Rep ListRecoveryGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListRecoveryGroupsResponse' 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', 'listRecoveryGroupsResponse_nextToken' - The token that identifies which batch of results you want to see.
--
-- 'recoveryGroups', 'listRecoveryGroupsResponse_recoveryGroups' - A list of recovery groups.
--
-- 'httpStatus', 'listRecoveryGroupsResponse_httpStatus' - The response's http status code.
newListRecoveryGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListRecoveryGroupsResponse
newListRecoveryGroupsResponse :: Int -> ListRecoveryGroupsResponse
newListRecoveryGroupsResponse Int
pHttpStatus_ =
  ListRecoveryGroupsResponse'
    { $sel:nextToken:ListRecoveryGroupsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:recoveryGroups:ListRecoveryGroupsResponse' :: Maybe [RecoveryGroupOutput]
recoveryGroups = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListRecoveryGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token that identifies which batch of results you want to see.
listRecoveryGroupsResponse_nextToken :: Lens.Lens' ListRecoveryGroupsResponse (Prelude.Maybe Prelude.Text)
listRecoveryGroupsResponse_nextToken :: Lens' ListRecoveryGroupsResponse (Maybe Text)
listRecoveryGroupsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecoveryGroupsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRecoveryGroupsResponse' :: ListRecoveryGroupsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRecoveryGroupsResponse
s@ListRecoveryGroupsResponse' {} Maybe Text
a -> ListRecoveryGroupsResponse
s {$sel:nextToken:ListRecoveryGroupsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListRecoveryGroupsResponse)

-- | A list of recovery groups.
listRecoveryGroupsResponse_recoveryGroups :: Lens.Lens' ListRecoveryGroupsResponse (Prelude.Maybe [RecoveryGroupOutput])
listRecoveryGroupsResponse_recoveryGroups :: Lens' ListRecoveryGroupsResponse (Maybe [RecoveryGroupOutput])
listRecoveryGroupsResponse_recoveryGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecoveryGroupsResponse' {Maybe [RecoveryGroupOutput]
recoveryGroups :: Maybe [RecoveryGroupOutput]
$sel:recoveryGroups:ListRecoveryGroupsResponse' :: ListRecoveryGroupsResponse -> Maybe [RecoveryGroupOutput]
recoveryGroups} -> Maybe [RecoveryGroupOutput]
recoveryGroups) (\s :: ListRecoveryGroupsResponse
s@ListRecoveryGroupsResponse' {} Maybe [RecoveryGroupOutput]
a -> ListRecoveryGroupsResponse
s {$sel:recoveryGroups:ListRecoveryGroupsResponse' :: Maybe [RecoveryGroupOutput]
recoveryGroups = Maybe [RecoveryGroupOutput]
a} :: ListRecoveryGroupsResponse) 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.
listRecoveryGroupsResponse_httpStatus :: Lens.Lens' ListRecoveryGroupsResponse Prelude.Int
listRecoveryGroupsResponse_httpStatus :: Lens' ListRecoveryGroupsResponse Int
listRecoveryGroupsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRecoveryGroupsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListRecoveryGroupsResponse' :: ListRecoveryGroupsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListRecoveryGroupsResponse
s@ListRecoveryGroupsResponse' {} Int
a -> ListRecoveryGroupsResponse
s {$sel:httpStatus:ListRecoveryGroupsResponse' :: Int
httpStatus = Int
a} :: ListRecoveryGroupsResponse)

instance Prelude.NFData ListRecoveryGroupsResponse where
  rnf :: ListRecoveryGroupsResponse -> ()
rnf ListRecoveryGroupsResponse' {Int
Maybe [RecoveryGroupOutput]
Maybe Text
httpStatus :: Int
recoveryGroups :: Maybe [RecoveryGroupOutput]
nextToken :: Maybe Text
$sel:httpStatus:ListRecoveryGroupsResponse' :: ListRecoveryGroupsResponse -> Int
$sel:recoveryGroups:ListRecoveryGroupsResponse' :: ListRecoveryGroupsResponse -> Maybe [RecoveryGroupOutput]
$sel:nextToken:ListRecoveryGroupsResponse' :: ListRecoveryGroupsResponse -> 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 [RecoveryGroupOutput]
recoveryGroups
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus