{-# 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.ListCells
-- 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 cells for an account.
--
-- This operation returns paginated results.
module Amazonka.Route53RecoveryReadiness.ListCells
  ( -- * Creating a Request
    ListCells (..),
    newListCells,

    -- * Request Lenses
    listCells_maxResults,
    listCells_nextToken,

    -- * Destructuring the Response
    ListCellsResponse (..),
    newListCellsResponse,

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

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

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

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

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

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

-- |
-- Create a value of 'ListCellsResponse' 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:
--
-- 'cells', 'listCellsResponse_cells' - A list of cells.
--
-- 'nextToken', 'listCellsResponse_nextToken' - The token that identifies which batch of results you want to see.
--
-- 'httpStatus', 'listCellsResponse_httpStatus' - The response's http status code.
newListCellsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListCellsResponse
newListCellsResponse :: Int -> ListCellsResponse
newListCellsResponse Int
pHttpStatus_ =
  ListCellsResponse'
    { $sel:cells:ListCellsResponse' :: Maybe [CellOutput]
cells = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCellsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListCellsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of cells.
listCellsResponse_cells :: Lens.Lens' ListCellsResponse (Prelude.Maybe [CellOutput])
listCellsResponse_cells :: Lens' ListCellsResponse (Maybe [CellOutput])
listCellsResponse_cells = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCellsResponse' {Maybe [CellOutput]
cells :: Maybe [CellOutput]
$sel:cells:ListCellsResponse' :: ListCellsResponse -> Maybe [CellOutput]
cells} -> Maybe [CellOutput]
cells) (\s :: ListCellsResponse
s@ListCellsResponse' {} Maybe [CellOutput]
a -> ListCellsResponse
s {$sel:cells:ListCellsResponse' :: Maybe [CellOutput]
cells = Maybe [CellOutput]
a} :: ListCellsResponse) 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 token that identifies which batch of results you want to see.
listCellsResponse_nextToken :: Lens.Lens' ListCellsResponse (Prelude.Maybe Prelude.Text)
listCellsResponse_nextToken :: Lens' ListCellsResponse (Maybe Text)
listCellsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCellsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCellsResponse' :: ListCellsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCellsResponse
s@ListCellsResponse' {} Maybe Text
a -> ListCellsResponse
s {$sel:nextToken:ListCellsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListCellsResponse)

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

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