{-# 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.GamesParks.ListStages
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets a paginated list of stage summaries from the game.
--
-- This operation returns paginated results.
module Amazonka.GamesParks.ListStages
  ( -- * Creating a Request
    ListStages (..),
    newListStages,

    -- * Request Lenses
    listStages_maxResults,
    listStages_nextToken,
    listStages_gameName,

    -- * Destructuring the Response
    ListStagesResponse (..),
    newListStagesResponse,

    -- * Response Lenses
    listStagesResponse_nextToken,
    listStagesResponse_stages,
    listStagesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListStages' smart constructor.
data ListStages = ListStages'
  { -- | The maximum number of results to return.
    --
    -- Use this parameter with NextToken to get results as a set of sequential
    -- pages.
    ListStages -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token that indicates the start of the next sequential page of
    -- results.
    --
    -- Use the token that is returned with a previous call to this operation.
    -- To start at the beginning of the result set, do not specify a value.
    ListStages -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the game.
    ListStages -> Text
gameName :: Prelude.Text
  }
  deriving (ListStages -> ListStages -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStages -> ListStages -> Bool
$c/= :: ListStages -> ListStages -> Bool
== :: ListStages -> ListStages -> Bool
$c== :: ListStages -> ListStages -> Bool
Prelude.Eq, ReadPrec [ListStages]
ReadPrec ListStages
Int -> ReadS ListStages
ReadS [ListStages]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStages]
$creadListPrec :: ReadPrec [ListStages]
readPrec :: ReadPrec ListStages
$creadPrec :: ReadPrec ListStages
readList :: ReadS [ListStages]
$creadList :: ReadS [ListStages]
readsPrec :: Int -> ReadS ListStages
$creadsPrec :: Int -> ReadS ListStages
Prelude.Read, Int -> ListStages -> ShowS
[ListStages] -> ShowS
ListStages -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStages] -> ShowS
$cshowList :: [ListStages] -> ShowS
show :: ListStages -> String
$cshow :: ListStages -> String
showsPrec :: Int -> ListStages -> ShowS
$cshowsPrec :: Int -> ListStages -> ShowS
Prelude.Show, forall x. Rep ListStages x -> ListStages
forall x. ListStages -> Rep ListStages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStages x -> ListStages
$cfrom :: forall x. ListStages -> Rep ListStages x
Prelude.Generic)

-- |
-- Create a value of 'ListStages' 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', 'listStages_maxResults' - The maximum number of results to return.
--
-- Use this parameter with NextToken to get results as a set of sequential
-- pages.
--
-- 'nextToken', 'listStages_nextToken' - The token that indicates the start of the next sequential page of
-- results.
--
-- Use the token that is returned with a previous call to this operation.
-- To start at the beginning of the result set, do not specify a value.
--
-- 'gameName', 'listStages_gameName' - The name of the game.
newListStages ::
  -- | 'gameName'
  Prelude.Text ->
  ListStages
newListStages :: Text -> ListStages
newListStages Text
pGameName_ =
  ListStages'
    { $sel:maxResults:ListStages' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListStages' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:gameName:ListStages' :: Text
gameName = Text
pGameName_
    }

-- | The maximum number of results to return.
--
-- Use this parameter with NextToken to get results as a set of sequential
-- pages.
listStages_maxResults :: Lens.Lens' ListStages (Prelude.Maybe Prelude.Natural)
listStages_maxResults :: Lens' ListStages (Maybe Natural)
listStages_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStages' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListStages' :: ListStages -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListStages
s@ListStages' {} Maybe Natural
a -> ListStages
s {$sel:maxResults:ListStages' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListStages)

-- | The token that indicates the start of the next sequential page of
-- results.
--
-- Use the token that is returned with a previous call to this operation.
-- To start at the beginning of the result set, do not specify a value.
listStages_nextToken :: Lens.Lens' ListStages (Prelude.Maybe Prelude.Text)
listStages_nextToken :: Lens' ListStages (Maybe Text)
listStages_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStages' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStages' :: ListStages -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStages
s@ListStages' {} Maybe Text
a -> ListStages
s {$sel:nextToken:ListStages' :: Maybe Text
nextToken = Maybe Text
a} :: ListStages)

-- | The name of the game.
listStages_gameName :: Lens.Lens' ListStages Prelude.Text
listStages_gameName :: Lens' ListStages Text
listStages_gameName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStages' {Text
gameName :: Text
$sel:gameName:ListStages' :: ListStages -> Text
gameName} -> Text
gameName) (\s :: ListStages
s@ListStages' {} Text
a -> ListStages
s {$sel:gameName:ListStages' :: Text
gameName = Text
a} :: ListStages)

instance Core.AWSPager ListStages where
  page :: ListStages -> AWSResponse ListStages -> Maybe ListStages
page ListStages
rq AWSResponse ListStages
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStages
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListStagesResponse (Maybe Text)
listStagesResponse_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 ListStages
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListStagesResponse (Maybe [StageSummary])
listStagesResponse_stages
            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.$ ListStages
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListStages (Maybe Text)
listStages_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListStages
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListStagesResponse (Maybe Text)
listStagesResponse_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 ListStages where
  type AWSResponse ListStages = ListStagesResponse
  request :: (Service -> Service) -> ListStages -> Request ListStages
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 ListStages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListStages)))
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 [StageSummary] -> Int -> ListStagesResponse
ListStagesResponse'
            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
"Stages" 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 ListStages where
  hashWithSalt :: Int -> ListStages -> Int
hashWithSalt Int
_salt ListStages' {Maybe Natural
Maybe Text
Text
gameName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:gameName:ListStages' :: ListStages -> Text
$sel:nextToken:ListStages' :: ListStages -> Maybe Text
$sel:maxResults:ListStages' :: ListStages -> 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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gameName

instance Prelude.NFData ListStages where
  rnf :: ListStages -> ()
rnf ListStages' {Maybe Natural
Maybe Text
Text
gameName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:gameName:ListStages' :: ListStages -> Text
$sel:nextToken:ListStages' :: ListStages -> Maybe Text
$sel:maxResults:ListStages' :: ListStages -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
gameName

instance Data.ToHeaders ListStages where
  toHeaders :: ListStages -> 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 ListStages where
  toPath :: ListStages -> ByteString
toPath ListStages' {Maybe Natural
Maybe Text
Text
gameName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:gameName:ListStages' :: ListStages -> Text
$sel:nextToken:ListStages' :: ListStages -> Maybe Text
$sel:maxResults:ListStages' :: ListStages -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/game/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
gameName, ByteString
"/stage"]

instance Data.ToQuery ListStages where
  toQuery :: ListStages -> QueryString
toQuery ListStages' {Maybe Natural
Maybe Text
Text
gameName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:gameName:ListStages' :: ListStages -> Text
$sel:nextToken:ListStages' :: ListStages -> Maybe Text
$sel:maxResults:ListStages' :: ListStages -> 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:/ 'newListStagesResponse' smart constructor.
data ListStagesResponse = ListStagesResponse'
  { -- | The token that indicates the start of the next sequential page of
    -- results.
    --
    -- Use this value when making the next call to this operation to continue
    -- where the last one finished.
    ListStagesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of stage summaries. You can use the stage names in the
    -- @UpdateStage@ and @GetStage@ actions.
    ListStagesResponse -> Maybe [StageSummary]
stages :: Prelude.Maybe [StageSummary],
    -- | The response's http status code.
    ListStagesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListStagesResponse -> ListStagesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStagesResponse -> ListStagesResponse -> Bool
$c/= :: ListStagesResponse -> ListStagesResponse -> Bool
== :: ListStagesResponse -> ListStagesResponse -> Bool
$c== :: ListStagesResponse -> ListStagesResponse -> Bool
Prelude.Eq, ReadPrec [ListStagesResponse]
ReadPrec ListStagesResponse
Int -> ReadS ListStagesResponse
ReadS [ListStagesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStagesResponse]
$creadListPrec :: ReadPrec [ListStagesResponse]
readPrec :: ReadPrec ListStagesResponse
$creadPrec :: ReadPrec ListStagesResponse
readList :: ReadS [ListStagesResponse]
$creadList :: ReadS [ListStagesResponse]
readsPrec :: Int -> ReadS ListStagesResponse
$creadsPrec :: Int -> ReadS ListStagesResponse
Prelude.Read, Int -> ListStagesResponse -> ShowS
[ListStagesResponse] -> ShowS
ListStagesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStagesResponse] -> ShowS
$cshowList :: [ListStagesResponse] -> ShowS
show :: ListStagesResponse -> String
$cshow :: ListStagesResponse -> String
showsPrec :: Int -> ListStagesResponse -> ShowS
$cshowsPrec :: Int -> ListStagesResponse -> ShowS
Prelude.Show, forall x. Rep ListStagesResponse x -> ListStagesResponse
forall x. ListStagesResponse -> Rep ListStagesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStagesResponse x -> ListStagesResponse
$cfrom :: forall x. ListStagesResponse -> Rep ListStagesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListStagesResponse' 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', 'listStagesResponse_nextToken' - The token that indicates the start of the next sequential page of
-- results.
--
-- Use this value when making the next call to this operation to continue
-- where the last one finished.
--
-- 'stages', 'listStagesResponse_stages' - A list of stage summaries. You can use the stage names in the
-- @UpdateStage@ and @GetStage@ actions.
--
-- 'httpStatus', 'listStagesResponse_httpStatus' - The response's http status code.
newListStagesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListStagesResponse
newListStagesResponse :: Int -> ListStagesResponse
newListStagesResponse Int
pHttpStatus_ =
  ListStagesResponse'
    { $sel:nextToken:ListStagesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:stages:ListStagesResponse' :: Maybe [StageSummary]
stages = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListStagesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token that indicates the start of the next sequential page of
-- results.
--
-- Use this value when making the next call to this operation to continue
-- where the last one finished.
listStagesResponse_nextToken :: Lens.Lens' ListStagesResponse (Prelude.Maybe Prelude.Text)
listStagesResponse_nextToken :: Lens' ListStagesResponse (Maybe Text)
listStagesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStagesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStagesResponse' :: ListStagesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStagesResponse
s@ListStagesResponse' {} Maybe Text
a -> ListStagesResponse
s {$sel:nextToken:ListStagesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListStagesResponse)

-- | A list of stage summaries. You can use the stage names in the
-- @UpdateStage@ and @GetStage@ actions.
listStagesResponse_stages :: Lens.Lens' ListStagesResponse (Prelude.Maybe [StageSummary])
listStagesResponse_stages :: Lens' ListStagesResponse (Maybe [StageSummary])
listStagesResponse_stages = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStagesResponse' {Maybe [StageSummary]
stages :: Maybe [StageSummary]
$sel:stages:ListStagesResponse' :: ListStagesResponse -> Maybe [StageSummary]
stages} -> Maybe [StageSummary]
stages) (\s :: ListStagesResponse
s@ListStagesResponse' {} Maybe [StageSummary]
a -> ListStagesResponse
s {$sel:stages:ListStagesResponse' :: Maybe [StageSummary]
stages = Maybe [StageSummary]
a} :: ListStagesResponse) 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.
listStagesResponse_httpStatus :: Lens.Lens' ListStagesResponse Prelude.Int
listStagesResponse_httpStatus :: Lens' ListStagesResponse Int
listStagesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStagesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListStagesResponse' :: ListStagesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListStagesResponse
s@ListStagesResponse' {} Int
a -> ListStagesResponse
s {$sel:httpStatus:ListStagesResponse' :: Int
httpStatus = Int
a} :: ListStagesResponse)

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