{-# 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.DescribeGameSessions
-- 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)
--
-- Retrieves a set of one or more game sessions in a specific fleet
-- location. You can optionally filter the results by current game session
-- status. Alternatively, use SearchGameSessions to request a set of active
-- game sessions that are filtered by certain criteria. To retrieve the
-- protection policy for game sessions, use DescribeGameSessionDetails.
--
-- This operation can be used in the following ways:
--
-- -   To retrieve all game sessions that are currently running on all
--     locations in a fleet, provide a fleet or alias ID, with an optional
--     status filter. This approach returns all game sessions in the
--     fleet\'s home Region and all remote locations.
--
-- -   To retrieve all game sessions that are currently running on a
--     specific fleet location, provide a fleet or alias ID and a location
--     name, with optional status filter. The location can be the fleet\'s
--     home Region or any remote location.
--
-- -   To retrieve a specific game session, provide the game session ID.
--     This approach looks for the game session ID in all fleets that
--     reside in the AWS Region defined in the request.
--
-- Use the pagination parameters to retrieve results as a set of sequential
-- pages.
--
-- If successful, a @GameSession@ object is returned for each game session
-- that matches the request.
--
-- /Available in GameLift Local./
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-client-api.html#gamelift-sdk-client-api-find Find a game session>
--
-- __Related actions__
--
-- CreateGameSession | DescribeGameSessions | DescribeGameSessionDetails |
-- SearchGameSessions | UpdateGameSession | GetGameSessionLogUrl |
-- StartGameSessionPlacement | DescribeGameSessionPlacement |
-- StopGameSessionPlacement |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
--
-- This operation returns paginated results.
module Amazonka.GameLift.DescribeGameSessions
  ( -- * Creating a Request
    DescribeGameSessions (..),
    newDescribeGameSessions,

    -- * Request Lenses
    describeGameSessions_location,
    describeGameSessions_gameSessionId,
    describeGameSessions_aliasId,
    describeGameSessions_nextToken,
    describeGameSessions_statusFilter,
    describeGameSessions_limit,
    describeGameSessions_fleetId,

    -- * Destructuring the Response
    DescribeGameSessionsResponse (..),
    newDescribeGameSessionsResponse,

    -- * Response Lenses
    describeGameSessionsResponse_gameSessions,
    describeGameSessionsResponse_nextToken,
    describeGameSessionsResponse_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

-- | Represents the input for a request operation.
--
-- /See:/ 'newDescribeGameSessions' smart constructor.
data DescribeGameSessions = DescribeGameSessions'
  { -- | A fleet location to get game session details for. You can specify a
    -- fleet\'s home Region or a remote location. Use the AWS Region code
    -- format, such as @us-west-2@.
    DescribeGameSessions -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the game session to retrieve.
    DescribeGameSessions -> Maybe Text
gameSessionId :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the alias associated with the fleet to retrieve
    -- game sessions for. You can use either the alias ID or ARN value.
    DescribeGameSessions -> Maybe Text
aliasId :: Prelude.Maybe Prelude.Text,
    -- | 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.
    DescribeGameSessions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Game session status to filter results on. You can filter on the
    -- following states: @ACTIVE@, @TERMINATED@, @ACTIVATING@, and
    -- @TERMINATING@. The last two are transitory and used for only very brief
    -- periods of time.
    DescribeGameSessions -> Maybe Text
statusFilter :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return. Use this parameter with
    -- @NextToken@ to get results as a set of sequential pages.
    DescribeGameSessions -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | A unique identifier for the fleet to retrieve game sessions for. You can
    -- use either the fleet ID or ARN value.
    DescribeGameSessions -> Maybe Text
fleetId :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeGameSessions -> DescribeGameSessions -> Bool
(DescribeGameSessions -> DescribeGameSessions -> Bool)
-> (DescribeGameSessions -> DescribeGameSessions -> Bool)
-> Eq DescribeGameSessions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGameSessions -> DescribeGameSessions -> Bool
$c/= :: DescribeGameSessions -> DescribeGameSessions -> Bool
== :: DescribeGameSessions -> DescribeGameSessions -> Bool
$c== :: DescribeGameSessions -> DescribeGameSessions -> Bool
Prelude.Eq, ReadPrec [DescribeGameSessions]
ReadPrec DescribeGameSessions
Int -> ReadS DescribeGameSessions
ReadS [DescribeGameSessions]
(Int -> ReadS DescribeGameSessions)
-> ReadS [DescribeGameSessions]
-> ReadPrec DescribeGameSessions
-> ReadPrec [DescribeGameSessions]
-> Read DescribeGameSessions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGameSessions]
$creadListPrec :: ReadPrec [DescribeGameSessions]
readPrec :: ReadPrec DescribeGameSessions
$creadPrec :: ReadPrec DescribeGameSessions
readList :: ReadS [DescribeGameSessions]
$creadList :: ReadS [DescribeGameSessions]
readsPrec :: Int -> ReadS DescribeGameSessions
$creadsPrec :: Int -> ReadS DescribeGameSessions
Prelude.Read, Int -> DescribeGameSessions -> ShowS
[DescribeGameSessions] -> ShowS
DescribeGameSessions -> String
(Int -> DescribeGameSessions -> ShowS)
-> (DescribeGameSessions -> String)
-> ([DescribeGameSessions] -> ShowS)
-> Show DescribeGameSessions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGameSessions] -> ShowS
$cshowList :: [DescribeGameSessions] -> ShowS
show :: DescribeGameSessions -> String
$cshow :: DescribeGameSessions -> String
showsPrec :: Int -> DescribeGameSessions -> ShowS
$cshowsPrec :: Int -> DescribeGameSessions -> ShowS
Prelude.Show, (forall x. DescribeGameSessions -> Rep DescribeGameSessions x)
-> (forall x. Rep DescribeGameSessions x -> DescribeGameSessions)
-> Generic DescribeGameSessions
forall x. Rep DescribeGameSessions x -> DescribeGameSessions
forall x. DescribeGameSessions -> Rep DescribeGameSessions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeGameSessions x -> DescribeGameSessions
$cfrom :: forall x. DescribeGameSessions -> Rep DescribeGameSessions x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGameSessions' 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:
--
-- 'location', 'describeGameSessions_location' - A fleet location to get game session details for. You can specify a
-- fleet\'s home Region or a remote location. Use the AWS Region code
-- format, such as @us-west-2@.
--
-- 'gameSessionId', 'describeGameSessions_gameSessionId' - A unique identifier for the game session to retrieve.
--
-- 'aliasId', 'describeGameSessions_aliasId' - A unique identifier for the alias associated with the fleet to retrieve
-- game sessions for. You can use either the alias ID or ARN value.
--
-- 'nextToken', 'describeGameSessions_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.
--
-- 'statusFilter', 'describeGameSessions_statusFilter' - Game session status to filter results on. You can filter on the
-- following states: @ACTIVE@, @TERMINATED@, @ACTIVATING@, and
-- @TERMINATING@. The last two are transitory and used for only very brief
-- periods of time.
--
-- 'limit', 'describeGameSessions_limit' - The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages.
--
-- 'fleetId', 'describeGameSessions_fleetId' - A unique identifier for the fleet to retrieve game sessions for. You can
-- use either the fleet ID or ARN value.
newDescribeGameSessions ::
  DescribeGameSessions
newDescribeGameSessions :: DescribeGameSessions
newDescribeGameSessions =
  DescribeGameSessions' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> DescribeGameSessions
DescribeGameSessions'
    { $sel:location:DescribeGameSessions' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:gameSessionId:DescribeGameSessions' :: Maybe Text
gameSessionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:aliasId:DescribeGameSessions' :: Maybe Text
aliasId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeGameSessions' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statusFilter:DescribeGameSessions' :: Maybe Text
statusFilter = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeGameSessions' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:fleetId:DescribeGameSessions' :: Maybe Text
fleetId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A fleet location to get game session details for. You can specify a
-- fleet\'s home Region or a remote location. Use the AWS Region code
-- format, such as @us-west-2@.
describeGameSessions_location :: Lens.Lens' DescribeGameSessions (Prelude.Maybe Prelude.Text)
describeGameSessions_location :: (Maybe Text -> f (Maybe Text))
-> DescribeGameSessions -> f DescribeGameSessions
describeGameSessions_location = (DescribeGameSessions -> Maybe Text)
-> (DescribeGameSessions -> Maybe Text -> DescribeGameSessions)
-> Lens
     DescribeGameSessions DescribeGameSessions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameSessions' {Maybe Text
location :: Maybe Text
$sel:location:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
location} -> Maybe Text
location) (\s :: DescribeGameSessions
s@DescribeGameSessions' {} Maybe Text
a -> DescribeGameSessions
s {$sel:location:DescribeGameSessions' :: Maybe Text
location = Maybe Text
a} :: DescribeGameSessions)

-- | A unique identifier for the game session to retrieve.
describeGameSessions_gameSessionId :: Lens.Lens' DescribeGameSessions (Prelude.Maybe Prelude.Text)
describeGameSessions_gameSessionId :: (Maybe Text -> f (Maybe Text))
-> DescribeGameSessions -> f DescribeGameSessions
describeGameSessions_gameSessionId = (DescribeGameSessions -> Maybe Text)
-> (DescribeGameSessions -> Maybe Text -> DescribeGameSessions)
-> Lens
     DescribeGameSessions DescribeGameSessions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameSessions' {Maybe Text
gameSessionId :: Maybe Text
$sel:gameSessionId:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
gameSessionId} -> Maybe Text
gameSessionId) (\s :: DescribeGameSessions
s@DescribeGameSessions' {} Maybe Text
a -> DescribeGameSessions
s {$sel:gameSessionId:DescribeGameSessions' :: Maybe Text
gameSessionId = Maybe Text
a} :: DescribeGameSessions)

-- | A unique identifier for the alias associated with the fleet to retrieve
-- game sessions for. You can use either the alias ID or ARN value.
describeGameSessions_aliasId :: Lens.Lens' DescribeGameSessions (Prelude.Maybe Prelude.Text)
describeGameSessions_aliasId :: (Maybe Text -> f (Maybe Text))
-> DescribeGameSessions -> f DescribeGameSessions
describeGameSessions_aliasId = (DescribeGameSessions -> Maybe Text)
-> (DescribeGameSessions -> Maybe Text -> DescribeGameSessions)
-> Lens
     DescribeGameSessions DescribeGameSessions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameSessions' {Maybe Text
aliasId :: Maybe Text
$sel:aliasId:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
aliasId} -> Maybe Text
aliasId) (\s :: DescribeGameSessions
s@DescribeGameSessions' {} Maybe Text
a -> DescribeGameSessions
s {$sel:aliasId:DescribeGameSessions' :: Maybe Text
aliasId = Maybe Text
a} :: DescribeGameSessions)

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

-- | Game session status to filter results on. You can filter on the
-- following states: @ACTIVE@, @TERMINATED@, @ACTIVATING@, and
-- @TERMINATING@. The last two are transitory and used for only very brief
-- periods of time.
describeGameSessions_statusFilter :: Lens.Lens' DescribeGameSessions (Prelude.Maybe Prelude.Text)
describeGameSessions_statusFilter :: (Maybe Text -> f (Maybe Text))
-> DescribeGameSessions -> f DescribeGameSessions
describeGameSessions_statusFilter = (DescribeGameSessions -> Maybe Text)
-> (DescribeGameSessions -> Maybe Text -> DescribeGameSessions)
-> Lens
     DescribeGameSessions DescribeGameSessions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameSessions' {Maybe Text
statusFilter :: Maybe Text
$sel:statusFilter:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
statusFilter} -> Maybe Text
statusFilter) (\s :: DescribeGameSessions
s@DescribeGameSessions' {} Maybe Text
a -> DescribeGameSessions
s {$sel:statusFilter:DescribeGameSessions' :: Maybe Text
statusFilter = Maybe Text
a} :: DescribeGameSessions)

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

-- | A unique identifier for the fleet to retrieve game sessions for. You can
-- use either the fleet ID or ARN value.
describeGameSessions_fleetId :: Lens.Lens' DescribeGameSessions (Prelude.Maybe Prelude.Text)
describeGameSessions_fleetId :: (Maybe Text -> f (Maybe Text))
-> DescribeGameSessions -> f DescribeGameSessions
describeGameSessions_fleetId = (DescribeGameSessions -> Maybe Text)
-> (DescribeGameSessions -> Maybe Text -> DescribeGameSessions)
-> Lens
     DescribeGameSessions DescribeGameSessions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameSessions' {Maybe Text
fleetId :: Maybe Text
$sel:fleetId:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
fleetId} -> Maybe Text
fleetId) (\s :: DescribeGameSessions
s@DescribeGameSessions' {} Maybe Text
a -> DescribeGameSessions
s {$sel:fleetId:DescribeGameSessions' :: Maybe Text
fleetId = Maybe Text
a} :: DescribeGameSessions)

instance Core.AWSPager DescribeGameSessions where
  page :: DescribeGameSessions
-> AWSResponse DescribeGameSessions -> Maybe DescribeGameSessions
page DescribeGameSessions
rq AWSResponse DescribeGameSessions
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeGameSessions
DescribeGameSessionsResponse
rs
            DescribeGameSessionsResponse
-> Getting (First Text) DescribeGameSessionsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeGameSessionsResponse
-> Const (First Text) DescribeGameSessionsResponse
Lens' DescribeGameSessionsResponse (Maybe Text)
describeGameSessionsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeGameSessionsResponse
 -> Const (First Text) DescribeGameSessionsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeGameSessionsResponse 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 DescribeGameSessions
forall a. Maybe a
Prelude.Nothing
    | Maybe [GameSession] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeGameSessions
DescribeGameSessionsResponse
rs
            DescribeGameSessionsResponse
-> Getting
     (First [GameSession]) DescribeGameSessionsResponse [GameSession]
-> Maybe [GameSession]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [GameSession]
 -> Const (First [GameSession]) (Maybe [GameSession]))
-> DescribeGameSessionsResponse
-> Const (First [GameSession]) DescribeGameSessionsResponse
Lens' DescribeGameSessionsResponse (Maybe [GameSession])
describeGameSessionsResponse_gameSessions
              ((Maybe [GameSession]
  -> Const (First [GameSession]) (Maybe [GameSession]))
 -> DescribeGameSessionsResponse
 -> Const (First [GameSession]) DescribeGameSessionsResponse)
-> (([GameSession] -> Const (First [GameSession]) [GameSession])
    -> Maybe [GameSession]
    -> Const (First [GameSession]) (Maybe [GameSession]))
-> Getting
     (First [GameSession]) DescribeGameSessionsResponse [GameSession]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([GameSession] -> Const (First [GameSession]) [GameSession])
-> Maybe [GameSession]
-> Const (First [GameSession]) (Maybe [GameSession])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeGameSessions
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeGameSessions -> Maybe DescribeGameSessions
forall a. a -> Maybe a
Prelude.Just (DescribeGameSessions -> Maybe DescribeGameSessions)
-> DescribeGameSessions -> Maybe DescribeGameSessions
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeGameSessions
rq
          DescribeGameSessions
-> (DescribeGameSessions -> DescribeGameSessions)
-> DescribeGameSessions
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeGameSessions -> Identity DescribeGameSessions
Lens
  DescribeGameSessions DescribeGameSessions (Maybe Text) (Maybe Text)
describeGameSessions_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeGameSessions -> Identity DescribeGameSessions)
-> Maybe Text -> DescribeGameSessions -> DescribeGameSessions
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeGameSessions
DescribeGameSessionsResponse
rs
          DescribeGameSessionsResponse
-> Getting (First Text) DescribeGameSessionsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeGameSessionsResponse
-> Const (First Text) DescribeGameSessionsResponse
Lens' DescribeGameSessionsResponse (Maybe Text)
describeGameSessionsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeGameSessionsResponse
 -> Const (First Text) DescribeGameSessionsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeGameSessionsResponse 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 DescribeGameSessions where
  type
    AWSResponse DescribeGameSessions =
      DescribeGameSessionsResponse
  request :: DescribeGameSessions -> Request DescribeGameSessions
request = Service -> DescribeGameSessions -> Request DescribeGameSessions
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeGameSessions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeGameSessions)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeGameSessions))
-> Logger
-> Service
-> Proxy DescribeGameSessions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeGameSessions)))
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 [GameSession]
-> Maybe Text -> Int -> DescribeGameSessionsResponse
DescribeGameSessionsResponse'
            (Maybe [GameSession]
 -> Maybe Text -> Int -> DescribeGameSessionsResponse)
-> Either String (Maybe [GameSession])
-> Either
     String (Maybe Text -> Int -> DescribeGameSessionsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [GameSession]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GameSessions" Either String (Maybe (Maybe [GameSession]))
-> Maybe [GameSession] -> Either String (Maybe [GameSession])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [GameSession]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> DescribeGameSessionsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeGameSessionsResponse)
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 -> DescribeGameSessionsResponse)
-> Either String Int -> Either String DescribeGameSessionsResponse
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 DescribeGameSessions

instance Prelude.NFData DescribeGameSessions

instance Core.ToHeaders DescribeGameSessions where
  toHeaders :: DescribeGameSessions -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeGameSessions -> 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.DescribeGameSessions" ::
                          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 DescribeGameSessions where
  toJSON :: DescribeGameSessions -> Value
toJSON DescribeGameSessions' {Maybe Natural
Maybe Text
fleetId :: Maybe Text
limit :: Maybe Natural
statusFilter :: Maybe Text
nextToken :: Maybe Text
aliasId :: Maybe Text
gameSessionId :: Maybe Text
location :: Maybe Text
$sel:fleetId:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
$sel:limit:DescribeGameSessions' :: DescribeGameSessions -> Maybe Natural
$sel:statusFilter:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
$sel:nextToken:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
$sel:aliasId:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
$sel:gameSessionId:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
$sel:location:DescribeGameSessions' :: DescribeGameSessions -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Location" 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
location,
            (Text
"GameSessionId" 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
gameSessionId,
            (Text
"AliasId" 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
aliasId,
            (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
"StatusFilter" 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
statusFilter,
            (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,
            (Text
"FleetId" 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
fleetId
          ]
      )

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

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

-- | Represents the returned data in response to a request operation.
--
-- /See:/ 'newDescribeGameSessionsResponse' smart constructor.
data DescribeGameSessionsResponse = DescribeGameSessionsResponse'
  { -- | A collection of properties for each game session that matches the
    -- request.
    DescribeGameSessionsResponse -> Maybe [GameSession]
gameSessions :: Prelude.Maybe [GameSession],
    -- | 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.
    DescribeGameSessionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeGameSessionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeGameSessionsResponse
-> DescribeGameSessionsResponse -> Bool
(DescribeGameSessionsResponse
 -> DescribeGameSessionsResponse -> Bool)
-> (DescribeGameSessionsResponse
    -> DescribeGameSessionsResponse -> Bool)
-> Eq DescribeGameSessionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGameSessionsResponse
-> DescribeGameSessionsResponse -> Bool
$c/= :: DescribeGameSessionsResponse
-> DescribeGameSessionsResponse -> Bool
== :: DescribeGameSessionsResponse
-> DescribeGameSessionsResponse -> Bool
$c== :: DescribeGameSessionsResponse
-> DescribeGameSessionsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeGameSessionsResponse]
ReadPrec DescribeGameSessionsResponse
Int -> ReadS DescribeGameSessionsResponse
ReadS [DescribeGameSessionsResponse]
(Int -> ReadS DescribeGameSessionsResponse)
-> ReadS [DescribeGameSessionsResponse]
-> ReadPrec DescribeGameSessionsResponse
-> ReadPrec [DescribeGameSessionsResponse]
-> Read DescribeGameSessionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGameSessionsResponse]
$creadListPrec :: ReadPrec [DescribeGameSessionsResponse]
readPrec :: ReadPrec DescribeGameSessionsResponse
$creadPrec :: ReadPrec DescribeGameSessionsResponse
readList :: ReadS [DescribeGameSessionsResponse]
$creadList :: ReadS [DescribeGameSessionsResponse]
readsPrec :: Int -> ReadS DescribeGameSessionsResponse
$creadsPrec :: Int -> ReadS DescribeGameSessionsResponse
Prelude.Read, Int -> DescribeGameSessionsResponse -> ShowS
[DescribeGameSessionsResponse] -> ShowS
DescribeGameSessionsResponse -> String
(Int -> DescribeGameSessionsResponse -> ShowS)
-> (DescribeGameSessionsResponse -> String)
-> ([DescribeGameSessionsResponse] -> ShowS)
-> Show DescribeGameSessionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGameSessionsResponse] -> ShowS
$cshowList :: [DescribeGameSessionsResponse] -> ShowS
show :: DescribeGameSessionsResponse -> String
$cshow :: DescribeGameSessionsResponse -> String
showsPrec :: Int -> DescribeGameSessionsResponse -> ShowS
$cshowsPrec :: Int -> DescribeGameSessionsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeGameSessionsResponse -> Rep DescribeGameSessionsResponse x)
-> (forall x.
    Rep DescribeGameSessionsResponse x -> DescribeGameSessionsResponse)
-> Generic DescribeGameSessionsResponse
forall x.
Rep DescribeGameSessionsResponse x -> DescribeGameSessionsResponse
forall x.
DescribeGameSessionsResponse -> Rep DescribeGameSessionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeGameSessionsResponse x -> DescribeGameSessionsResponse
$cfrom :: forall x.
DescribeGameSessionsResponse -> Rep DescribeGameSessionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGameSessionsResponse' 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:
--
-- 'gameSessions', 'describeGameSessionsResponse_gameSessions' - A collection of properties for each game session that matches the
-- request.
--
-- 'nextToken', 'describeGameSessionsResponse_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', 'describeGameSessionsResponse_httpStatus' - The response's http status code.
newDescribeGameSessionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeGameSessionsResponse
newDescribeGameSessionsResponse :: Int -> DescribeGameSessionsResponse
newDescribeGameSessionsResponse Int
pHttpStatus_ =
  DescribeGameSessionsResponse' :: Maybe [GameSession]
-> Maybe Text -> Int -> DescribeGameSessionsResponse
DescribeGameSessionsResponse'
    { $sel:gameSessions:DescribeGameSessionsResponse' :: Maybe [GameSession]
gameSessions =
        Maybe [GameSession]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeGameSessionsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeGameSessionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A collection of properties for each game session that matches the
-- request.
describeGameSessionsResponse_gameSessions :: Lens.Lens' DescribeGameSessionsResponse (Prelude.Maybe [GameSession])
describeGameSessionsResponse_gameSessions :: (Maybe [GameSession] -> f (Maybe [GameSession]))
-> DescribeGameSessionsResponse -> f DescribeGameSessionsResponse
describeGameSessionsResponse_gameSessions = (DescribeGameSessionsResponse -> Maybe [GameSession])
-> (DescribeGameSessionsResponse
    -> Maybe [GameSession] -> DescribeGameSessionsResponse)
-> Lens' DescribeGameSessionsResponse (Maybe [GameSession])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameSessionsResponse' {Maybe [GameSession]
gameSessions :: Maybe [GameSession]
$sel:gameSessions:DescribeGameSessionsResponse' :: DescribeGameSessionsResponse -> Maybe [GameSession]
gameSessions} -> Maybe [GameSession]
gameSessions) (\s :: DescribeGameSessionsResponse
s@DescribeGameSessionsResponse' {} Maybe [GameSession]
a -> DescribeGameSessionsResponse
s {$sel:gameSessions:DescribeGameSessionsResponse' :: Maybe [GameSession]
gameSessions = Maybe [GameSession]
a} :: DescribeGameSessionsResponse) ((Maybe [GameSession] -> f (Maybe [GameSession]))
 -> DescribeGameSessionsResponse -> f DescribeGameSessionsResponse)
-> ((Maybe [GameSession] -> f (Maybe [GameSession]))
    -> Maybe [GameSession] -> f (Maybe [GameSession]))
-> (Maybe [GameSession] -> f (Maybe [GameSession]))
-> DescribeGameSessionsResponse
-> f DescribeGameSessionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [GameSession] [GameSession] [GameSession] [GameSession]
-> Iso
     (Maybe [GameSession])
     (Maybe [GameSession])
     (Maybe [GameSession])
     (Maybe [GameSession])
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 [GameSession] [GameSession] [GameSession] [GameSession]
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.
describeGameSessionsResponse_nextToken :: Lens.Lens' DescribeGameSessionsResponse (Prelude.Maybe Prelude.Text)
describeGameSessionsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeGameSessionsResponse -> f DescribeGameSessionsResponse
describeGameSessionsResponse_nextToken = (DescribeGameSessionsResponse -> Maybe Text)
-> (DescribeGameSessionsResponse
    -> Maybe Text -> DescribeGameSessionsResponse)
-> Lens' DescribeGameSessionsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameSessionsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeGameSessionsResponse' :: DescribeGameSessionsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeGameSessionsResponse
s@DescribeGameSessionsResponse' {} Maybe Text
a -> DescribeGameSessionsResponse
s {$sel:nextToken:DescribeGameSessionsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeGameSessionsResponse)

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

instance Prelude.NFData DescribeGameSessionsResponse