{-# 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.GameLift.ListGameServerGroups
-- 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 a game server groups.
--
-- This operation returns paginated results.
module Amazonka.GameLift.ListGameServerGroups
  ( -- * Creating a Request
    ListGameServerGroups (..),
    newListGameServerGroups,

    -- * Request Lenses
    listGameServerGroups_limit,
    listGameServerGroups_nextToken,

    -- * Destructuring the Response
    ListGameServerGroupsResponse (..),
    newListGameServerGroupsResponse,

    -- * Response Lenses
    listGameServerGroupsResponse_gameServerGroups,
    listGameServerGroupsResponse_nextToken,
    listGameServerGroupsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListGameServerGroups' smart constructor.
data ListGameServerGroups = ListGameServerGroups'
  { -- | The game server groups\' limit.
    ListGameServerGroups -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | Specify the pagination token from a previous request to retrieve the
    -- next page of results.
    ListGameServerGroups -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListGameServerGroups -> ListGameServerGroups -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGameServerGroups -> ListGameServerGroups -> Bool
$c/= :: ListGameServerGroups -> ListGameServerGroups -> Bool
== :: ListGameServerGroups -> ListGameServerGroups -> Bool
$c== :: ListGameServerGroups -> ListGameServerGroups -> Bool
Prelude.Eq, ReadPrec [ListGameServerGroups]
ReadPrec ListGameServerGroups
Int -> ReadS ListGameServerGroups
ReadS [ListGameServerGroups]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGameServerGroups]
$creadListPrec :: ReadPrec [ListGameServerGroups]
readPrec :: ReadPrec ListGameServerGroups
$creadPrec :: ReadPrec ListGameServerGroups
readList :: ReadS [ListGameServerGroups]
$creadList :: ReadS [ListGameServerGroups]
readsPrec :: Int -> ReadS ListGameServerGroups
$creadsPrec :: Int -> ReadS ListGameServerGroups
Prelude.Read, Int -> ListGameServerGroups -> ShowS
[ListGameServerGroups] -> ShowS
ListGameServerGroups -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGameServerGroups] -> ShowS
$cshowList :: [ListGameServerGroups] -> ShowS
show :: ListGameServerGroups -> String
$cshow :: ListGameServerGroups -> String
showsPrec :: Int -> ListGameServerGroups -> ShowS
$cshowsPrec :: Int -> ListGameServerGroups -> ShowS
Prelude.Show, forall x. Rep ListGameServerGroups x -> ListGameServerGroups
forall x. ListGameServerGroups -> Rep ListGameServerGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListGameServerGroups x -> ListGameServerGroups
$cfrom :: forall x. ListGameServerGroups -> Rep ListGameServerGroups x
Prelude.Generic)

-- |
-- Create a value of 'ListGameServerGroups' 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:
--
-- 'limit', 'listGameServerGroups_limit' - The game server groups\' limit.
--
-- 'nextToken', 'listGameServerGroups_nextToken' - Specify the pagination token from a previous request to retrieve the
-- next page of results.
newListGameServerGroups ::
  ListGameServerGroups
newListGameServerGroups :: ListGameServerGroups
newListGameServerGroups =
  ListGameServerGroups'
    { $sel:limit:ListGameServerGroups' :: Maybe Natural
limit = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListGameServerGroups' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The game server groups\' limit.
listGameServerGroups_limit :: Lens.Lens' ListGameServerGroups (Prelude.Maybe Prelude.Natural)
listGameServerGroups_limit :: Lens' ListGameServerGroups (Maybe Natural)
listGameServerGroups_limit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGameServerGroups' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListGameServerGroups' :: ListGameServerGroups -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListGameServerGroups
s@ListGameServerGroups' {} Maybe Natural
a -> ListGameServerGroups
s {$sel:limit:ListGameServerGroups' :: Maybe Natural
limit = Maybe Natural
a} :: ListGameServerGroups)

-- | Specify the pagination token from a previous request to retrieve the
-- next page of results.
listGameServerGroups_nextToken :: Lens.Lens' ListGameServerGroups (Prelude.Maybe Prelude.Text)
listGameServerGroups_nextToken :: Lens' ListGameServerGroups (Maybe Text)
listGameServerGroups_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGameServerGroups' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGameServerGroups' :: ListGameServerGroups -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGameServerGroups
s@ListGameServerGroups' {} Maybe Text
a -> ListGameServerGroups
s {$sel:nextToken:ListGameServerGroups' :: Maybe Text
nextToken = Maybe Text
a} :: ListGameServerGroups)

instance Core.AWSPager ListGameServerGroups where
  page :: ListGameServerGroups
-> AWSResponse ListGameServerGroups -> Maybe ListGameServerGroups
page ListGameServerGroups
rq AWSResponse ListGameServerGroups
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListGameServerGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListGameServerGroupsResponse (Maybe Text)
listGameServerGroupsResponse_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 ListGameServerGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListGameServerGroupsResponse (Maybe [GameServerGroup])
listGameServerGroupsResponse_gameServerGroups
            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.$ ListGameServerGroups
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListGameServerGroups (Maybe Text)
listGameServerGroups_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListGameServerGroups
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListGameServerGroupsResponse (Maybe Text)
listGameServerGroupsResponse_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 ListGameServerGroups where
  type
    AWSResponse ListGameServerGroups =
      ListGameServerGroupsResponse
  request :: (Service -> Service)
-> ListGameServerGroups -> Request ListGameServerGroups
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 ListGameServerGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListGameServerGroups)))
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 [GameServerGroup]
-> Maybe Text -> Int -> ListGameServerGroupsResponse
ListGameServerGroupsResponse'
            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
"GameServerGroups"
                            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 ListGameServerGroups where
  hashWithSalt :: Int -> ListGameServerGroups -> Int
hashWithSalt Int
_salt ListGameServerGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
limit :: Maybe Natural
$sel:nextToken:ListGameServerGroups' :: ListGameServerGroups -> Maybe Text
$sel:limit:ListGameServerGroups' :: ListGameServerGroups -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
limit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

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

instance Data.ToHeaders ListGameServerGroups where
  toHeaders :: ListGameServerGroups -> 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
"GameLift.ListGameServerGroups" ::
                          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 ListGameServerGroups where
  toJSON :: ListGameServerGroups -> Value
toJSON ListGameServerGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
limit :: Maybe Natural
$sel:nextToken:ListGameServerGroups' :: ListGameServerGroups -> Maybe Text
$sel:limit:ListGameServerGroups' :: ListGameServerGroups -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Limit" 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
limit,
            (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 ListGameServerGroups where
  toPath :: ListGameServerGroups -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListGameServerGroupsResponse' smart constructor.
data ListGameServerGroupsResponse = ListGameServerGroupsResponse'
  { -- | The game server groups\' game server groups.
    ListGameServerGroupsResponse -> Maybe [GameServerGroup]
gameServerGroups :: Prelude.Maybe [GameServerGroup],
    -- | Specify the pagination token from a previous request to retrieve the
    -- next page of results.
    ListGameServerGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListGameServerGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListGameServerGroupsResponse
-> ListGameServerGroupsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGameServerGroupsResponse
-> ListGameServerGroupsResponse -> Bool
$c/= :: ListGameServerGroupsResponse
-> ListGameServerGroupsResponse -> Bool
== :: ListGameServerGroupsResponse
-> ListGameServerGroupsResponse -> Bool
$c== :: ListGameServerGroupsResponse
-> ListGameServerGroupsResponse -> Bool
Prelude.Eq, ReadPrec [ListGameServerGroupsResponse]
ReadPrec ListGameServerGroupsResponse
Int -> ReadS ListGameServerGroupsResponse
ReadS [ListGameServerGroupsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGameServerGroupsResponse]
$creadListPrec :: ReadPrec [ListGameServerGroupsResponse]
readPrec :: ReadPrec ListGameServerGroupsResponse
$creadPrec :: ReadPrec ListGameServerGroupsResponse
readList :: ReadS [ListGameServerGroupsResponse]
$creadList :: ReadS [ListGameServerGroupsResponse]
readsPrec :: Int -> ReadS ListGameServerGroupsResponse
$creadsPrec :: Int -> ReadS ListGameServerGroupsResponse
Prelude.Read, Int -> ListGameServerGroupsResponse -> ShowS
[ListGameServerGroupsResponse] -> ShowS
ListGameServerGroupsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGameServerGroupsResponse] -> ShowS
$cshowList :: [ListGameServerGroupsResponse] -> ShowS
show :: ListGameServerGroupsResponse -> String
$cshow :: ListGameServerGroupsResponse -> String
showsPrec :: Int -> ListGameServerGroupsResponse -> ShowS
$cshowsPrec :: Int -> ListGameServerGroupsResponse -> ShowS
Prelude.Show, forall x.
Rep ListGameServerGroupsResponse x -> ListGameServerGroupsResponse
forall x.
ListGameServerGroupsResponse -> Rep ListGameServerGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListGameServerGroupsResponse x -> ListGameServerGroupsResponse
$cfrom :: forall x.
ListGameServerGroupsResponse -> Rep ListGameServerGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListGameServerGroupsResponse' 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:
--
-- 'gameServerGroups', 'listGameServerGroupsResponse_gameServerGroups' - The game server groups\' game server groups.
--
-- 'nextToken', 'listGameServerGroupsResponse_nextToken' - Specify the pagination token from a previous request to retrieve the
-- next page of results.
--
-- 'httpStatus', 'listGameServerGroupsResponse_httpStatus' - The response's http status code.
newListGameServerGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListGameServerGroupsResponse
newListGameServerGroupsResponse :: Int -> ListGameServerGroupsResponse
newListGameServerGroupsResponse Int
pHttpStatus_ =
  ListGameServerGroupsResponse'
    { $sel:gameServerGroups:ListGameServerGroupsResponse' :: Maybe [GameServerGroup]
gameServerGroups =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListGameServerGroupsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListGameServerGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The game server groups\' game server groups.
listGameServerGroupsResponse_gameServerGroups :: Lens.Lens' ListGameServerGroupsResponse (Prelude.Maybe [GameServerGroup])
listGameServerGroupsResponse_gameServerGroups :: Lens' ListGameServerGroupsResponse (Maybe [GameServerGroup])
listGameServerGroupsResponse_gameServerGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGameServerGroupsResponse' {Maybe [GameServerGroup]
gameServerGroups :: Maybe [GameServerGroup]
$sel:gameServerGroups:ListGameServerGroupsResponse' :: ListGameServerGroupsResponse -> Maybe [GameServerGroup]
gameServerGroups} -> Maybe [GameServerGroup]
gameServerGroups) (\s :: ListGameServerGroupsResponse
s@ListGameServerGroupsResponse' {} Maybe [GameServerGroup]
a -> ListGameServerGroupsResponse
s {$sel:gameServerGroups:ListGameServerGroupsResponse' :: Maybe [GameServerGroup]
gameServerGroups = Maybe [GameServerGroup]
a} :: ListGameServerGroupsResponse) 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

-- | Specify the pagination token from a previous request to retrieve the
-- next page of results.
listGameServerGroupsResponse_nextToken :: Lens.Lens' ListGameServerGroupsResponse (Prelude.Maybe Prelude.Text)
listGameServerGroupsResponse_nextToken :: Lens' ListGameServerGroupsResponse (Maybe Text)
listGameServerGroupsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGameServerGroupsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGameServerGroupsResponse' :: ListGameServerGroupsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGameServerGroupsResponse
s@ListGameServerGroupsResponse' {} Maybe Text
a -> ListGameServerGroupsResponse
s {$sel:nextToken:ListGameServerGroupsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListGameServerGroupsResponse)

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

instance Prelude.NFData ListGameServerGroupsResponse where
  rnf :: ListGameServerGroupsResponse -> ()
rnf ListGameServerGroupsResponse' {Int
Maybe [GameServerGroup]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
gameServerGroups :: Maybe [GameServerGroup]
$sel:httpStatus:ListGameServerGroupsResponse' :: ListGameServerGroupsResponse -> Int
$sel:nextToken:ListGameServerGroupsResponse' :: ListGameServerGroupsResponse -> Maybe Text
$sel:gameServerGroups:ListGameServerGroupsResponse' :: ListGameServerGroupsResponse -> Maybe [GameServerGroup]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [GameServerGroup]
gameServerGroups
      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