{-# 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.DescribeGameServerInstances
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- __This operation is used with the GameLift FleetIQ solution and game
-- server groups.__
--
-- Retrieves status information about the Amazon EC2 instances associated
-- with a GameLift FleetIQ game server group. Use this operation to detect
-- when instances are active or not available to host new game servers. If
-- you are looking for instance configuration information, call
-- DescribeGameServerGroup or access the corresponding Auto Scaling group
-- properties.
--
-- To request status for all instances in the game server group, provide a
-- game server group ID only. To request status for specific instances,
-- provide the game server group ID and one or more instance IDs. Use the
-- pagination parameters to retrieve results in sequential segments. If
-- successful, a collection of @GameServerInstance@ objects is returned.
--
-- This operation is not designed to be called with every game server claim
-- request; this practice can cause you to exceed your API limit, which
-- results in errors. Instead, as a best practice, cache the results and
-- refresh your cache no more than once every 10 seconds.
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-intro.html GameLift FleetIQ Guide>
--
-- __Related actions__
--
-- CreateGameServerGroup | ListGameServerGroups | DescribeGameServerGroup |
-- UpdateGameServerGroup | DeleteGameServerGroup | ResumeGameServerGroup |
-- SuspendGameServerGroup | DescribeGameServerInstances |
-- <https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/reference-awssdk-fleetiq.html All APIs by task>
--
-- This operation returns paginated results.
module Amazonka.GameLift.DescribeGameServerInstances
  ( -- * Creating a Request
    DescribeGameServerInstances (..),
    newDescribeGameServerInstances,

    -- * Request Lenses
    describeGameServerInstances_nextToken,
    describeGameServerInstances_instanceIds,
    describeGameServerInstances_limit,
    describeGameServerInstances_gameServerGroupName,

    -- * Destructuring the Response
    DescribeGameServerInstancesResponse (..),
    newDescribeGameServerInstancesResponse,

    -- * Response Lenses
    describeGameServerInstancesResponse_gameServerInstances,
    describeGameServerInstancesResponse_nextToken,
    describeGameServerInstancesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeGameServerInstances' smart constructor.
data DescribeGameServerInstances = DescribeGameServerInstances'
  { -- | A 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.
    DescribeGameServerInstances -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The EC2 instance IDs that you want to retrieve status on. EC2 instance
    -- IDs use a 17-character format, for example: @i-1234567890abcdef0@. To
    -- retrieve all instances in the game server group, leave this parameter
    -- empty.
    DescribeGameServerInstances -> Maybe (NonEmpty Text)
instanceIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The maximum number of results to return. Use this parameter with
    -- @NextToken@ to get results as a set of sequential pages.
    DescribeGameServerInstances -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | A unique identifier for the game server group. Use either the
    -- GameServerGroup name or ARN value.
    DescribeGameServerInstances -> Text
gameServerGroupName :: Prelude.Text
  }
  deriving (DescribeGameServerInstances -> DescribeGameServerInstances -> Bool
(DescribeGameServerInstances
 -> DescribeGameServerInstances -> Bool)
-> (DescribeGameServerInstances
    -> DescribeGameServerInstances -> Bool)
-> Eq DescribeGameServerInstances
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGameServerInstances -> DescribeGameServerInstances -> Bool
$c/= :: DescribeGameServerInstances -> DescribeGameServerInstances -> Bool
== :: DescribeGameServerInstances -> DescribeGameServerInstances -> Bool
$c== :: DescribeGameServerInstances -> DescribeGameServerInstances -> Bool
Prelude.Eq, ReadPrec [DescribeGameServerInstances]
ReadPrec DescribeGameServerInstances
Int -> ReadS DescribeGameServerInstances
ReadS [DescribeGameServerInstances]
(Int -> ReadS DescribeGameServerInstances)
-> ReadS [DescribeGameServerInstances]
-> ReadPrec DescribeGameServerInstances
-> ReadPrec [DescribeGameServerInstances]
-> Read DescribeGameServerInstances
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGameServerInstances]
$creadListPrec :: ReadPrec [DescribeGameServerInstances]
readPrec :: ReadPrec DescribeGameServerInstances
$creadPrec :: ReadPrec DescribeGameServerInstances
readList :: ReadS [DescribeGameServerInstances]
$creadList :: ReadS [DescribeGameServerInstances]
readsPrec :: Int -> ReadS DescribeGameServerInstances
$creadsPrec :: Int -> ReadS DescribeGameServerInstances
Prelude.Read, Int -> DescribeGameServerInstances -> ShowS
[DescribeGameServerInstances] -> ShowS
DescribeGameServerInstances -> String
(Int -> DescribeGameServerInstances -> ShowS)
-> (DescribeGameServerInstances -> String)
-> ([DescribeGameServerInstances] -> ShowS)
-> Show DescribeGameServerInstances
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGameServerInstances] -> ShowS
$cshowList :: [DescribeGameServerInstances] -> ShowS
show :: DescribeGameServerInstances -> String
$cshow :: DescribeGameServerInstances -> String
showsPrec :: Int -> DescribeGameServerInstances -> ShowS
$cshowsPrec :: Int -> DescribeGameServerInstances -> ShowS
Prelude.Show, (forall x.
 DescribeGameServerInstances -> Rep DescribeGameServerInstances x)
-> (forall x.
    Rep DescribeGameServerInstances x -> DescribeGameServerInstances)
-> Generic DescribeGameServerInstances
forall x.
Rep DescribeGameServerInstances x -> DescribeGameServerInstances
forall x.
DescribeGameServerInstances -> Rep DescribeGameServerInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeGameServerInstances x -> DescribeGameServerInstances
$cfrom :: forall x.
DescribeGameServerInstances -> Rep DescribeGameServerInstances x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGameServerInstances' 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', 'describeGameServerInstances_nextToken' - A 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.
--
-- 'instanceIds', 'describeGameServerInstances_instanceIds' - The EC2 instance IDs that you want to retrieve status on. EC2 instance
-- IDs use a 17-character format, for example: @i-1234567890abcdef0@. To
-- retrieve all instances in the game server group, leave this parameter
-- empty.
--
-- 'limit', 'describeGameServerInstances_limit' - The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages.
--
-- 'gameServerGroupName', 'describeGameServerInstances_gameServerGroupName' - A unique identifier for the game server group. Use either the
-- GameServerGroup name or ARN value.
newDescribeGameServerInstances ::
  -- | 'gameServerGroupName'
  Prelude.Text ->
  DescribeGameServerInstances
newDescribeGameServerInstances :: Text -> DescribeGameServerInstances
newDescribeGameServerInstances Text
pGameServerGroupName_ =
  DescribeGameServerInstances' :: Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe Natural
-> Text
-> DescribeGameServerInstances
DescribeGameServerInstances'
    { $sel:nextToken:DescribeGameServerInstances' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceIds:DescribeGameServerInstances' :: Maybe (NonEmpty Text)
instanceIds = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeGameServerInstances' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:gameServerGroupName:DescribeGameServerInstances' :: Text
gameServerGroupName = Text
pGameServerGroupName_
    }

-- | A 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.
describeGameServerInstances_nextToken :: Lens.Lens' DescribeGameServerInstances (Prelude.Maybe Prelude.Text)
describeGameServerInstances_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeGameServerInstances -> f DescribeGameServerInstances
describeGameServerInstances_nextToken = (DescribeGameServerInstances -> Maybe Text)
-> (DescribeGameServerInstances
    -> Maybe Text -> DescribeGameServerInstances)
-> Lens
     DescribeGameServerInstances
     DescribeGameServerInstances
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameServerInstances' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeGameServerInstances' :: DescribeGameServerInstances -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeGameServerInstances
s@DescribeGameServerInstances' {} Maybe Text
a -> DescribeGameServerInstances
s {$sel:nextToken:DescribeGameServerInstances' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeGameServerInstances)

-- | The EC2 instance IDs that you want to retrieve status on. EC2 instance
-- IDs use a 17-character format, for example: @i-1234567890abcdef0@. To
-- retrieve all instances in the game server group, leave this parameter
-- empty.
describeGameServerInstances_instanceIds :: Lens.Lens' DescribeGameServerInstances (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
describeGameServerInstances_instanceIds :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DescribeGameServerInstances -> f DescribeGameServerInstances
describeGameServerInstances_instanceIds = (DescribeGameServerInstances -> Maybe (NonEmpty Text))
-> (DescribeGameServerInstances
    -> Maybe (NonEmpty Text) -> DescribeGameServerInstances)
-> Lens
     DescribeGameServerInstances
     DescribeGameServerInstances
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameServerInstances' {Maybe (NonEmpty Text)
instanceIds :: Maybe (NonEmpty Text)
$sel:instanceIds:DescribeGameServerInstances' :: DescribeGameServerInstances -> Maybe (NonEmpty Text)
instanceIds} -> Maybe (NonEmpty Text)
instanceIds) (\s :: DescribeGameServerInstances
s@DescribeGameServerInstances' {} Maybe (NonEmpty Text)
a -> DescribeGameServerInstances
s {$sel:instanceIds:DescribeGameServerInstances' :: Maybe (NonEmpty Text)
instanceIds = Maybe (NonEmpty Text)
a} :: DescribeGameServerInstances) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> DescribeGameServerInstances -> f DescribeGameServerInstances)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DescribeGameServerInstances
-> f DescribeGameServerInstances
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | A unique identifier for the game server group. Use either the
-- GameServerGroup name or ARN value.
describeGameServerInstances_gameServerGroupName :: Lens.Lens' DescribeGameServerInstances Prelude.Text
describeGameServerInstances_gameServerGroupName :: (Text -> f Text)
-> DescribeGameServerInstances -> f DescribeGameServerInstances
describeGameServerInstances_gameServerGroupName = (DescribeGameServerInstances -> Text)
-> (DescribeGameServerInstances
    -> Text -> DescribeGameServerInstances)
-> Lens
     DescribeGameServerInstances DescribeGameServerInstances Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameServerInstances' {Text
gameServerGroupName :: Text
$sel:gameServerGroupName:DescribeGameServerInstances' :: DescribeGameServerInstances -> Text
gameServerGroupName} -> Text
gameServerGroupName) (\s :: DescribeGameServerInstances
s@DescribeGameServerInstances' {} Text
a -> DescribeGameServerInstances
s {$sel:gameServerGroupName:DescribeGameServerInstances' :: Text
gameServerGroupName = Text
a} :: DescribeGameServerInstances)

instance Core.AWSPager DescribeGameServerInstances where
  page :: DescribeGameServerInstances
-> AWSResponse DescribeGameServerInstances
-> Maybe DescribeGameServerInstances
page DescribeGameServerInstances
rq AWSResponse DescribeGameServerInstances
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeGameServerInstances
DescribeGameServerInstancesResponse
rs
            DescribeGameServerInstancesResponse
-> Getting (First Text) DescribeGameServerInstancesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeGameServerInstancesResponse
-> Const (First Text) DescribeGameServerInstancesResponse
Lens' DescribeGameServerInstancesResponse (Maybe Text)
describeGameServerInstancesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeGameServerInstancesResponse
 -> Const (First Text) DescribeGameServerInstancesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeGameServerInstancesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeGameServerInstances
forall a. Maybe a
Prelude.Nothing
    | Maybe [GameServerInstance] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeGameServerInstances
DescribeGameServerInstancesResponse
rs
            DescribeGameServerInstancesResponse
-> Getting
     (First [GameServerInstance])
     DescribeGameServerInstancesResponse
     [GameServerInstance]
-> Maybe [GameServerInstance]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [GameServerInstance]
 -> Const (First [GameServerInstance]) (Maybe [GameServerInstance]))
-> DescribeGameServerInstancesResponse
-> Const
     (First [GameServerInstance]) DescribeGameServerInstancesResponse
Lens'
  DescribeGameServerInstancesResponse (Maybe [GameServerInstance])
describeGameServerInstancesResponse_gameServerInstances
              ((Maybe [GameServerInstance]
  -> Const (First [GameServerInstance]) (Maybe [GameServerInstance]))
 -> DescribeGameServerInstancesResponse
 -> Const
      (First [GameServerInstance]) DescribeGameServerInstancesResponse)
-> (([GameServerInstance]
     -> Const (First [GameServerInstance]) [GameServerInstance])
    -> Maybe [GameServerInstance]
    -> Const (First [GameServerInstance]) (Maybe [GameServerInstance]))
-> Getting
     (First [GameServerInstance])
     DescribeGameServerInstancesResponse
     [GameServerInstance]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([GameServerInstance]
 -> Const (First [GameServerInstance]) [GameServerInstance])
-> Maybe [GameServerInstance]
-> Const (First [GameServerInstance]) (Maybe [GameServerInstance])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeGameServerInstances
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeGameServerInstances -> Maybe DescribeGameServerInstances
forall a. a -> Maybe a
Prelude.Just (DescribeGameServerInstances -> Maybe DescribeGameServerInstances)
-> DescribeGameServerInstances -> Maybe DescribeGameServerInstances
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeGameServerInstances
rq
          DescribeGameServerInstances
-> (DescribeGameServerInstances -> DescribeGameServerInstances)
-> DescribeGameServerInstances
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeGameServerInstances
-> Identity DescribeGameServerInstances
Lens
  DescribeGameServerInstances
  DescribeGameServerInstances
  (Maybe Text)
  (Maybe Text)
describeGameServerInstances_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeGameServerInstances
 -> Identity DescribeGameServerInstances)
-> Maybe Text
-> DescribeGameServerInstances
-> DescribeGameServerInstances
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeGameServerInstances
DescribeGameServerInstancesResponse
rs
          DescribeGameServerInstancesResponse
-> Getting (First Text) DescribeGameServerInstancesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeGameServerInstancesResponse
-> Const (First Text) DescribeGameServerInstancesResponse
Lens' DescribeGameServerInstancesResponse (Maybe Text)
describeGameServerInstancesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeGameServerInstancesResponse
 -> Const (First Text) DescribeGameServerInstancesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeGameServerInstancesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeGameServerInstances where
  type
    AWSResponse DescribeGameServerInstances =
      DescribeGameServerInstancesResponse
  request :: DescribeGameServerInstances -> Request DescribeGameServerInstances
request = Service
-> DescribeGameServerInstances
-> Request DescribeGameServerInstances
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeGameServerInstances
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeGameServerInstances)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeGameServerInstances))
-> Logger
-> Service
-> Proxy DescribeGameServerInstances
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeGameServerInstances)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [GameServerInstance]
-> Maybe Text -> Int -> DescribeGameServerInstancesResponse
DescribeGameServerInstancesResponse'
            (Maybe [GameServerInstance]
 -> Maybe Text -> Int -> DescribeGameServerInstancesResponse)
-> Either String (Maybe [GameServerInstance])
-> Either
     String (Maybe Text -> Int -> DescribeGameServerInstancesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [GameServerInstance]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GameServerInstances"
                            Either String (Maybe (Maybe [GameServerInstance]))
-> Maybe [GameServerInstance]
-> Either String (Maybe [GameServerInstance])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [GameServerInstance]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String (Maybe Text -> Int -> DescribeGameServerInstancesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeGameServerInstancesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> DescribeGameServerInstancesResponse)
-> Either String Int
-> Either String DescribeGameServerInstancesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeGameServerInstances

instance Prelude.NFData DescribeGameServerInstances

instance Core.ToHeaders DescribeGameServerInstances where
  toHeaders :: DescribeGameServerInstances -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeGameServerInstances -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"GameLift.DescribeGameServerInstances" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeGameServerInstances where
  toJSON :: DescribeGameServerInstances -> Value
toJSON DescribeGameServerInstances' {Maybe Natural
Maybe (NonEmpty Text)
Maybe Text
Text
gameServerGroupName :: Text
limit :: Maybe Natural
instanceIds :: Maybe (NonEmpty Text)
nextToken :: Maybe Text
$sel:gameServerGroupName:DescribeGameServerInstances' :: DescribeGameServerInstances -> Text
$sel:limit:DescribeGameServerInstances' :: DescribeGameServerInstances -> Maybe Natural
$sel:instanceIds:DescribeGameServerInstances' :: DescribeGameServerInstances -> Maybe (NonEmpty Text)
$sel:nextToken:DescribeGameServerInstances' :: DescribeGameServerInstances -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"InstanceIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
instanceIds,
            (Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"GameServerGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gameServerGroupName)
          ]
      )

instance Core.ToPath DescribeGameServerInstances where
  toPath :: DescribeGameServerInstances -> ByteString
toPath = ByteString -> DescribeGameServerInstances -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeGameServerInstancesResponse' smart constructor.
data DescribeGameServerInstancesResponse = DescribeGameServerInstancesResponse'
  { -- | The collection of requested game server instances.
    DescribeGameServerInstancesResponse -> Maybe [GameServerInstance]
gameServerInstances :: Prelude.Maybe [GameServerInstance],
    -- | A token that indicates where to resume retrieving results on the next
    -- call to this operation. If no token is returned, these results represent
    -- the end of the list.
    DescribeGameServerInstancesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeGameServerInstancesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeGameServerInstancesResponse
-> DescribeGameServerInstancesResponse -> Bool
(DescribeGameServerInstancesResponse
 -> DescribeGameServerInstancesResponse -> Bool)
-> (DescribeGameServerInstancesResponse
    -> DescribeGameServerInstancesResponse -> Bool)
-> Eq DescribeGameServerInstancesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGameServerInstancesResponse
-> DescribeGameServerInstancesResponse -> Bool
$c/= :: DescribeGameServerInstancesResponse
-> DescribeGameServerInstancesResponse -> Bool
== :: DescribeGameServerInstancesResponse
-> DescribeGameServerInstancesResponse -> Bool
$c== :: DescribeGameServerInstancesResponse
-> DescribeGameServerInstancesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeGameServerInstancesResponse]
ReadPrec DescribeGameServerInstancesResponse
Int -> ReadS DescribeGameServerInstancesResponse
ReadS [DescribeGameServerInstancesResponse]
(Int -> ReadS DescribeGameServerInstancesResponse)
-> ReadS [DescribeGameServerInstancesResponse]
-> ReadPrec DescribeGameServerInstancesResponse
-> ReadPrec [DescribeGameServerInstancesResponse]
-> Read DescribeGameServerInstancesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGameServerInstancesResponse]
$creadListPrec :: ReadPrec [DescribeGameServerInstancesResponse]
readPrec :: ReadPrec DescribeGameServerInstancesResponse
$creadPrec :: ReadPrec DescribeGameServerInstancesResponse
readList :: ReadS [DescribeGameServerInstancesResponse]
$creadList :: ReadS [DescribeGameServerInstancesResponse]
readsPrec :: Int -> ReadS DescribeGameServerInstancesResponse
$creadsPrec :: Int -> ReadS DescribeGameServerInstancesResponse
Prelude.Read, Int -> DescribeGameServerInstancesResponse -> ShowS
[DescribeGameServerInstancesResponse] -> ShowS
DescribeGameServerInstancesResponse -> String
(Int -> DescribeGameServerInstancesResponse -> ShowS)
-> (DescribeGameServerInstancesResponse -> String)
-> ([DescribeGameServerInstancesResponse] -> ShowS)
-> Show DescribeGameServerInstancesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGameServerInstancesResponse] -> ShowS
$cshowList :: [DescribeGameServerInstancesResponse] -> ShowS
show :: DescribeGameServerInstancesResponse -> String
$cshow :: DescribeGameServerInstancesResponse -> String
showsPrec :: Int -> DescribeGameServerInstancesResponse -> ShowS
$cshowsPrec :: Int -> DescribeGameServerInstancesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeGameServerInstancesResponse
 -> Rep DescribeGameServerInstancesResponse x)
-> (forall x.
    Rep DescribeGameServerInstancesResponse x
    -> DescribeGameServerInstancesResponse)
-> Generic DescribeGameServerInstancesResponse
forall x.
Rep DescribeGameServerInstancesResponse x
-> DescribeGameServerInstancesResponse
forall x.
DescribeGameServerInstancesResponse
-> Rep DescribeGameServerInstancesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeGameServerInstancesResponse x
-> DescribeGameServerInstancesResponse
$cfrom :: forall x.
DescribeGameServerInstancesResponse
-> Rep DescribeGameServerInstancesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGameServerInstancesResponse' 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:
--
-- 'gameServerInstances', 'describeGameServerInstancesResponse_gameServerInstances' - The collection of requested game server instances.
--
-- 'nextToken', 'describeGameServerInstancesResponse_nextToken' - A token that indicates where to resume retrieving results on the next
-- call to this operation. If no token is returned, these results represent
-- the end of the list.
--
-- 'httpStatus', 'describeGameServerInstancesResponse_httpStatus' - The response's http status code.
newDescribeGameServerInstancesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeGameServerInstancesResponse
newDescribeGameServerInstancesResponse :: Int -> DescribeGameServerInstancesResponse
newDescribeGameServerInstancesResponse Int
pHttpStatus_ =
  DescribeGameServerInstancesResponse' :: Maybe [GameServerInstance]
-> Maybe Text -> Int -> DescribeGameServerInstancesResponse
DescribeGameServerInstancesResponse'
    { $sel:gameServerInstances:DescribeGameServerInstancesResponse' :: Maybe [GameServerInstance]
gameServerInstances =
        Maybe [GameServerInstance]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeGameServerInstancesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeGameServerInstancesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The collection of requested game server instances.
describeGameServerInstancesResponse_gameServerInstances :: Lens.Lens' DescribeGameServerInstancesResponse (Prelude.Maybe [GameServerInstance])
describeGameServerInstancesResponse_gameServerInstances :: (Maybe [GameServerInstance] -> f (Maybe [GameServerInstance]))
-> DescribeGameServerInstancesResponse
-> f DescribeGameServerInstancesResponse
describeGameServerInstancesResponse_gameServerInstances = (DescribeGameServerInstancesResponse -> Maybe [GameServerInstance])
-> (DescribeGameServerInstancesResponse
    -> Maybe [GameServerInstance]
    -> DescribeGameServerInstancesResponse)
-> Lens'
     DescribeGameServerInstancesResponse (Maybe [GameServerInstance])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameServerInstancesResponse' {Maybe [GameServerInstance]
gameServerInstances :: Maybe [GameServerInstance]
$sel:gameServerInstances:DescribeGameServerInstancesResponse' :: DescribeGameServerInstancesResponse -> Maybe [GameServerInstance]
gameServerInstances} -> Maybe [GameServerInstance]
gameServerInstances) (\s :: DescribeGameServerInstancesResponse
s@DescribeGameServerInstancesResponse' {} Maybe [GameServerInstance]
a -> DescribeGameServerInstancesResponse
s {$sel:gameServerInstances:DescribeGameServerInstancesResponse' :: Maybe [GameServerInstance]
gameServerInstances = Maybe [GameServerInstance]
a} :: DescribeGameServerInstancesResponse) ((Maybe [GameServerInstance] -> f (Maybe [GameServerInstance]))
 -> DescribeGameServerInstancesResponse
 -> f DescribeGameServerInstancesResponse)
-> ((Maybe [GameServerInstance] -> f (Maybe [GameServerInstance]))
    -> Maybe [GameServerInstance] -> f (Maybe [GameServerInstance]))
-> (Maybe [GameServerInstance] -> f (Maybe [GameServerInstance]))
-> DescribeGameServerInstancesResponse
-> f DescribeGameServerInstancesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GameServerInstance]
  [GameServerInstance]
  [GameServerInstance]
  [GameServerInstance]
-> Iso
     (Maybe [GameServerInstance])
     (Maybe [GameServerInstance])
     (Maybe [GameServerInstance])
     (Maybe [GameServerInstance])
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 AnIso
  [GameServerInstance]
  [GameServerInstance]
  [GameServerInstance]
  [GameServerInstance]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A token that indicates where to resume retrieving results on the next
-- call to this operation. If no token is returned, these results represent
-- the end of the list.
describeGameServerInstancesResponse_nextToken :: Lens.Lens' DescribeGameServerInstancesResponse (Prelude.Maybe Prelude.Text)
describeGameServerInstancesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeGameServerInstancesResponse
-> f DescribeGameServerInstancesResponse
describeGameServerInstancesResponse_nextToken = (DescribeGameServerInstancesResponse -> Maybe Text)
-> (DescribeGameServerInstancesResponse
    -> Maybe Text -> DescribeGameServerInstancesResponse)
-> Lens' DescribeGameServerInstancesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameServerInstancesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeGameServerInstancesResponse' :: DescribeGameServerInstancesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeGameServerInstancesResponse
s@DescribeGameServerInstancesResponse' {} Maybe Text
a -> DescribeGameServerInstancesResponse
s {$sel:nextToken:DescribeGameServerInstancesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeGameServerInstancesResponse)

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

instance
  Prelude.NFData
    DescribeGameServerInstancesResponse