{-# 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.DescribePlayerSessions
-- 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 properties for one or more player sessions.
--
-- This action can be used in the following ways:
--
-- -   To retrieve a specific player session, provide the player session ID
--     only.
--
-- -   To retrieve all player sessions in a game session, provide the game
--     session ID only.
--
-- -   To retrieve all player sessions for a specific player, provide a
--     player ID only.
--
-- To request player sessions, specify either a player session ID, game
-- session ID, or player ID. You can filter this request by player session
-- status. Use the pagination parameters to retrieve results as a set of
-- sequential pages.
--
-- If successful, a @PlayerSession@ object is returned for each session
-- that matches the request.
--
-- /Available in Amazon GameLift Local./
--
-- __Related actions__
--
-- CreatePlayerSession | CreatePlayerSessions | DescribePlayerSessions |
-- StartGameSessionPlacement | DescribeGameSessionPlacement |
-- <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.DescribePlayerSessions
  ( -- * Creating a Request
    DescribePlayerSessions (..),
    newDescribePlayerSessions,

    -- * Request Lenses
    describePlayerSessions_gameSessionId,
    describePlayerSessions_nextToken,
    describePlayerSessions_limit,
    describePlayerSessions_playerSessionId,
    describePlayerSessions_playerId,
    describePlayerSessions_playerSessionStatusFilter,

    -- * Destructuring the Response
    DescribePlayerSessionsResponse (..),
    newDescribePlayerSessionsResponse,

    -- * Response Lenses
    describePlayerSessionsResponse_nextToken,
    describePlayerSessionsResponse_playerSessions,
    describePlayerSessionsResponse_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:/ 'newDescribePlayerSessions' smart constructor.
data DescribePlayerSessions = DescribePlayerSessions'
  { -- | A unique identifier for the game session to retrieve player sessions
    -- for.
    DescribePlayerSessions -> Maybe Text
gameSessionId :: 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. If
    -- a player session ID is specified, this parameter is ignored.
    DescribePlayerSessions -> Maybe Text
nextToken :: 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. If a player
    -- session ID is specified, this parameter is ignored.
    DescribePlayerSessions -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | A unique identifier for a player session to retrieve.
    DescribePlayerSessions -> Maybe Text
playerSessionId :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for a player to retrieve player sessions for.
    DescribePlayerSessions -> Maybe Text
playerId :: Prelude.Maybe Prelude.Text,
    -- | Player session status to filter results on.
    --
    -- Possible player session statuses include the following:
    --
    -- -   __RESERVED__ -- The player session request has been received, but
    --     the player has not yet connected to the server process and\/or been
    --     validated.
    --
    -- -   __ACTIVE__ -- The player has been validated by the server process
    --     and is currently connected.
    --
    -- -   __COMPLETED__ -- The player connection has been dropped.
    --
    -- -   __TIMEDOUT__ -- A player session request was received, but the
    --     player did not connect and\/or was not validated within the timeout
    --     limit (60 seconds).
    DescribePlayerSessions -> Maybe Text
playerSessionStatusFilter :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribePlayerSessions -> DescribePlayerSessions -> Bool
(DescribePlayerSessions -> DescribePlayerSessions -> Bool)
-> (DescribePlayerSessions -> DescribePlayerSessions -> Bool)
-> Eq DescribePlayerSessions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePlayerSessions -> DescribePlayerSessions -> Bool
$c/= :: DescribePlayerSessions -> DescribePlayerSessions -> Bool
== :: DescribePlayerSessions -> DescribePlayerSessions -> Bool
$c== :: DescribePlayerSessions -> DescribePlayerSessions -> Bool
Prelude.Eq, ReadPrec [DescribePlayerSessions]
ReadPrec DescribePlayerSessions
Int -> ReadS DescribePlayerSessions
ReadS [DescribePlayerSessions]
(Int -> ReadS DescribePlayerSessions)
-> ReadS [DescribePlayerSessions]
-> ReadPrec DescribePlayerSessions
-> ReadPrec [DescribePlayerSessions]
-> Read DescribePlayerSessions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePlayerSessions]
$creadListPrec :: ReadPrec [DescribePlayerSessions]
readPrec :: ReadPrec DescribePlayerSessions
$creadPrec :: ReadPrec DescribePlayerSessions
readList :: ReadS [DescribePlayerSessions]
$creadList :: ReadS [DescribePlayerSessions]
readsPrec :: Int -> ReadS DescribePlayerSessions
$creadsPrec :: Int -> ReadS DescribePlayerSessions
Prelude.Read, Int -> DescribePlayerSessions -> ShowS
[DescribePlayerSessions] -> ShowS
DescribePlayerSessions -> String
(Int -> DescribePlayerSessions -> ShowS)
-> (DescribePlayerSessions -> String)
-> ([DescribePlayerSessions] -> ShowS)
-> Show DescribePlayerSessions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePlayerSessions] -> ShowS
$cshowList :: [DescribePlayerSessions] -> ShowS
show :: DescribePlayerSessions -> String
$cshow :: DescribePlayerSessions -> String
showsPrec :: Int -> DescribePlayerSessions -> ShowS
$cshowsPrec :: Int -> DescribePlayerSessions -> ShowS
Prelude.Show, (forall x. DescribePlayerSessions -> Rep DescribePlayerSessions x)
-> (forall x.
    Rep DescribePlayerSessions x -> DescribePlayerSessions)
-> Generic DescribePlayerSessions
forall x. Rep DescribePlayerSessions x -> DescribePlayerSessions
forall x. DescribePlayerSessions -> Rep DescribePlayerSessions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribePlayerSessions x -> DescribePlayerSessions
$cfrom :: forall x. DescribePlayerSessions -> Rep DescribePlayerSessions x
Prelude.Generic)

-- |
-- Create a value of 'DescribePlayerSessions' 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:
--
-- 'gameSessionId', 'describePlayerSessions_gameSessionId' - A unique identifier for the game session to retrieve player sessions
-- for.
--
-- 'nextToken', 'describePlayerSessions_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. If
-- a player session ID is specified, this parameter is ignored.
--
-- 'limit', 'describePlayerSessions_limit' - The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages. If a player
-- session ID is specified, this parameter is ignored.
--
-- 'playerSessionId', 'describePlayerSessions_playerSessionId' - A unique identifier for a player session to retrieve.
--
-- 'playerId', 'describePlayerSessions_playerId' - A unique identifier for a player to retrieve player sessions for.
--
-- 'playerSessionStatusFilter', 'describePlayerSessions_playerSessionStatusFilter' - Player session status to filter results on.
--
-- Possible player session statuses include the following:
--
-- -   __RESERVED__ -- The player session request has been received, but
--     the player has not yet connected to the server process and\/or been
--     validated.
--
-- -   __ACTIVE__ -- The player has been validated by the server process
--     and is currently connected.
--
-- -   __COMPLETED__ -- The player connection has been dropped.
--
-- -   __TIMEDOUT__ -- A player session request was received, but the
--     player did not connect and\/or was not validated within the timeout
--     limit (60 seconds).
newDescribePlayerSessions ::
  DescribePlayerSessions
newDescribePlayerSessions :: DescribePlayerSessions
newDescribePlayerSessions =
  DescribePlayerSessions' :: Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> DescribePlayerSessions
DescribePlayerSessions'
    { $sel:gameSessionId:DescribePlayerSessions' :: Maybe Text
gameSessionId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribePlayerSessions' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribePlayerSessions' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:playerSessionId:DescribePlayerSessions' :: Maybe Text
playerSessionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:playerId:DescribePlayerSessions' :: Maybe Text
playerId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:playerSessionStatusFilter:DescribePlayerSessions' :: Maybe Text
playerSessionStatusFilter = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | 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. If
-- a player session ID is specified, this parameter is ignored.
describePlayerSessions_nextToken :: Lens.Lens' DescribePlayerSessions (Prelude.Maybe Prelude.Text)
describePlayerSessions_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribePlayerSessions -> f DescribePlayerSessions
describePlayerSessions_nextToken = (DescribePlayerSessions -> Maybe Text)
-> (DescribePlayerSessions -> Maybe Text -> DescribePlayerSessions)
-> Lens
     DescribePlayerSessions
     DescribePlayerSessions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePlayerSessions' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribePlayerSessions
s@DescribePlayerSessions' {} Maybe Text
a -> DescribePlayerSessions
s {$sel:nextToken:DescribePlayerSessions' :: Maybe Text
nextToken = Maybe Text
a} :: DescribePlayerSessions)

-- | The maximum number of results to return. Use this parameter with
-- @NextToken@ to get results as a set of sequential pages. If a player
-- session ID is specified, this parameter is ignored.
describePlayerSessions_limit :: Lens.Lens' DescribePlayerSessions (Prelude.Maybe Prelude.Natural)
describePlayerSessions_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribePlayerSessions -> f DescribePlayerSessions
describePlayerSessions_limit = (DescribePlayerSessions -> Maybe Natural)
-> (DescribePlayerSessions
    -> Maybe Natural -> DescribePlayerSessions)
-> Lens
     DescribePlayerSessions
     DescribePlayerSessions
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePlayerSessions' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribePlayerSessions
s@DescribePlayerSessions' {} Maybe Natural
a -> DescribePlayerSessions
s {$sel:limit:DescribePlayerSessions' :: Maybe Natural
limit = Maybe Natural
a} :: DescribePlayerSessions)

-- | A unique identifier for a player session to retrieve.
describePlayerSessions_playerSessionId :: Lens.Lens' DescribePlayerSessions (Prelude.Maybe Prelude.Text)
describePlayerSessions_playerSessionId :: (Maybe Text -> f (Maybe Text))
-> DescribePlayerSessions -> f DescribePlayerSessions
describePlayerSessions_playerSessionId = (DescribePlayerSessions -> Maybe Text)
-> (DescribePlayerSessions -> Maybe Text -> DescribePlayerSessions)
-> Lens
     DescribePlayerSessions
     DescribePlayerSessions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePlayerSessions' {Maybe Text
playerSessionId :: Maybe Text
$sel:playerSessionId:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Text
playerSessionId} -> Maybe Text
playerSessionId) (\s :: DescribePlayerSessions
s@DescribePlayerSessions' {} Maybe Text
a -> DescribePlayerSessions
s {$sel:playerSessionId:DescribePlayerSessions' :: Maybe Text
playerSessionId = Maybe Text
a} :: DescribePlayerSessions)

-- | A unique identifier for a player to retrieve player sessions for.
describePlayerSessions_playerId :: Lens.Lens' DescribePlayerSessions (Prelude.Maybe Prelude.Text)
describePlayerSessions_playerId :: (Maybe Text -> f (Maybe Text))
-> DescribePlayerSessions -> f DescribePlayerSessions
describePlayerSessions_playerId = (DescribePlayerSessions -> Maybe Text)
-> (DescribePlayerSessions -> Maybe Text -> DescribePlayerSessions)
-> Lens
     DescribePlayerSessions
     DescribePlayerSessions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePlayerSessions' {Maybe Text
playerId :: Maybe Text
$sel:playerId:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Text
playerId} -> Maybe Text
playerId) (\s :: DescribePlayerSessions
s@DescribePlayerSessions' {} Maybe Text
a -> DescribePlayerSessions
s {$sel:playerId:DescribePlayerSessions' :: Maybe Text
playerId = Maybe Text
a} :: DescribePlayerSessions)

-- | Player session status to filter results on.
--
-- Possible player session statuses include the following:
--
-- -   __RESERVED__ -- The player session request has been received, but
--     the player has not yet connected to the server process and\/or been
--     validated.
--
-- -   __ACTIVE__ -- The player has been validated by the server process
--     and is currently connected.
--
-- -   __COMPLETED__ -- The player connection has been dropped.
--
-- -   __TIMEDOUT__ -- A player session request was received, but the
--     player did not connect and\/or was not validated within the timeout
--     limit (60 seconds).
describePlayerSessions_playerSessionStatusFilter :: Lens.Lens' DescribePlayerSessions (Prelude.Maybe Prelude.Text)
describePlayerSessions_playerSessionStatusFilter :: (Maybe Text -> f (Maybe Text))
-> DescribePlayerSessions -> f DescribePlayerSessions
describePlayerSessions_playerSessionStatusFilter = (DescribePlayerSessions -> Maybe Text)
-> (DescribePlayerSessions -> Maybe Text -> DescribePlayerSessions)
-> Lens
     DescribePlayerSessions
     DescribePlayerSessions
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePlayerSessions' {Maybe Text
playerSessionStatusFilter :: Maybe Text
$sel:playerSessionStatusFilter:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Text
playerSessionStatusFilter} -> Maybe Text
playerSessionStatusFilter) (\s :: DescribePlayerSessions
s@DescribePlayerSessions' {} Maybe Text
a -> DescribePlayerSessions
s {$sel:playerSessionStatusFilter:DescribePlayerSessions' :: Maybe Text
playerSessionStatusFilter = Maybe Text
a} :: DescribePlayerSessions)

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

instance Prelude.NFData DescribePlayerSessions

instance Core.ToHeaders DescribePlayerSessions where
  toHeaders :: DescribePlayerSessions -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribePlayerSessions -> 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.DescribePlayerSessions" ::
                          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 DescribePlayerSessions where
  toJSON :: DescribePlayerSessions -> Value
toJSON DescribePlayerSessions' {Maybe Natural
Maybe Text
playerSessionStatusFilter :: Maybe Text
playerId :: Maybe Text
playerSessionId :: Maybe Text
limit :: Maybe Natural
nextToken :: Maybe Text
gameSessionId :: Maybe Text
$sel:playerSessionStatusFilter:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Text
$sel:playerId:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Text
$sel:playerSessionId:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Text
$sel:limit:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Natural
$sel:nextToken:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Text
$sel:gameSessionId:DescribePlayerSessions' :: DescribePlayerSessions -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"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
"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
"PlayerSessionId" 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
playerSessionId,
            (Text
"PlayerId" 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
playerId,
            (Text
"PlayerSessionStatusFilter" 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
playerSessionStatusFilter
          ]
      )

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

instance Core.ToQuery DescribePlayerSessions where
  toQuery :: DescribePlayerSessions -> QueryString
toQuery = QueryString -> DescribePlayerSessions -> 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:/ 'newDescribePlayerSessionsResponse' smart constructor.
data DescribePlayerSessionsResponse = DescribePlayerSessionsResponse'
  { -- | 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.
    DescribePlayerSessionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A collection of objects containing properties for each player session
    -- that matches the request.
    DescribePlayerSessionsResponse -> Maybe [PlayerSession]
playerSessions :: Prelude.Maybe [PlayerSession],
    -- | The response's http status code.
    DescribePlayerSessionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribePlayerSessionsResponse
-> DescribePlayerSessionsResponse -> Bool
(DescribePlayerSessionsResponse
 -> DescribePlayerSessionsResponse -> Bool)
-> (DescribePlayerSessionsResponse
    -> DescribePlayerSessionsResponse -> Bool)
-> Eq DescribePlayerSessionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePlayerSessionsResponse
-> DescribePlayerSessionsResponse -> Bool
$c/= :: DescribePlayerSessionsResponse
-> DescribePlayerSessionsResponse -> Bool
== :: DescribePlayerSessionsResponse
-> DescribePlayerSessionsResponse -> Bool
$c== :: DescribePlayerSessionsResponse
-> DescribePlayerSessionsResponse -> Bool
Prelude.Eq, ReadPrec [DescribePlayerSessionsResponse]
ReadPrec DescribePlayerSessionsResponse
Int -> ReadS DescribePlayerSessionsResponse
ReadS [DescribePlayerSessionsResponse]
(Int -> ReadS DescribePlayerSessionsResponse)
-> ReadS [DescribePlayerSessionsResponse]
-> ReadPrec DescribePlayerSessionsResponse
-> ReadPrec [DescribePlayerSessionsResponse]
-> Read DescribePlayerSessionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePlayerSessionsResponse]
$creadListPrec :: ReadPrec [DescribePlayerSessionsResponse]
readPrec :: ReadPrec DescribePlayerSessionsResponse
$creadPrec :: ReadPrec DescribePlayerSessionsResponse
readList :: ReadS [DescribePlayerSessionsResponse]
$creadList :: ReadS [DescribePlayerSessionsResponse]
readsPrec :: Int -> ReadS DescribePlayerSessionsResponse
$creadsPrec :: Int -> ReadS DescribePlayerSessionsResponse
Prelude.Read, Int -> DescribePlayerSessionsResponse -> ShowS
[DescribePlayerSessionsResponse] -> ShowS
DescribePlayerSessionsResponse -> String
(Int -> DescribePlayerSessionsResponse -> ShowS)
-> (DescribePlayerSessionsResponse -> String)
-> ([DescribePlayerSessionsResponse] -> ShowS)
-> Show DescribePlayerSessionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePlayerSessionsResponse] -> ShowS
$cshowList :: [DescribePlayerSessionsResponse] -> ShowS
show :: DescribePlayerSessionsResponse -> String
$cshow :: DescribePlayerSessionsResponse -> String
showsPrec :: Int -> DescribePlayerSessionsResponse -> ShowS
$cshowsPrec :: Int -> DescribePlayerSessionsResponse -> ShowS
Prelude.Show, (forall x.
 DescribePlayerSessionsResponse
 -> Rep DescribePlayerSessionsResponse x)
-> (forall x.
    Rep DescribePlayerSessionsResponse x
    -> DescribePlayerSessionsResponse)
-> Generic DescribePlayerSessionsResponse
forall x.
Rep DescribePlayerSessionsResponse x
-> DescribePlayerSessionsResponse
forall x.
DescribePlayerSessionsResponse
-> Rep DescribePlayerSessionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribePlayerSessionsResponse x
-> DescribePlayerSessionsResponse
$cfrom :: forall x.
DescribePlayerSessionsResponse
-> Rep DescribePlayerSessionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribePlayerSessionsResponse' 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', 'describePlayerSessionsResponse_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.
--
-- 'playerSessions', 'describePlayerSessionsResponse_playerSessions' - A collection of objects containing properties for each player session
-- that matches the request.
--
-- 'httpStatus', 'describePlayerSessionsResponse_httpStatus' - The response's http status code.
newDescribePlayerSessionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribePlayerSessionsResponse
newDescribePlayerSessionsResponse :: Int -> DescribePlayerSessionsResponse
newDescribePlayerSessionsResponse Int
pHttpStatus_ =
  DescribePlayerSessionsResponse' :: Maybe Text
-> Maybe [PlayerSession] -> Int -> DescribePlayerSessionsResponse
DescribePlayerSessionsResponse'
    { $sel:nextToken:DescribePlayerSessionsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:playerSessions:DescribePlayerSessionsResponse' :: Maybe [PlayerSession]
playerSessions = Maybe [PlayerSession]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribePlayerSessionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | A collection of objects containing properties for each player session
-- that matches the request.
describePlayerSessionsResponse_playerSessions :: Lens.Lens' DescribePlayerSessionsResponse (Prelude.Maybe [PlayerSession])
describePlayerSessionsResponse_playerSessions :: (Maybe [PlayerSession] -> f (Maybe [PlayerSession]))
-> DescribePlayerSessionsResponse
-> f DescribePlayerSessionsResponse
describePlayerSessionsResponse_playerSessions = (DescribePlayerSessionsResponse -> Maybe [PlayerSession])
-> (DescribePlayerSessionsResponse
    -> Maybe [PlayerSession] -> DescribePlayerSessionsResponse)
-> Lens' DescribePlayerSessionsResponse (Maybe [PlayerSession])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePlayerSessionsResponse' {Maybe [PlayerSession]
playerSessions :: Maybe [PlayerSession]
$sel:playerSessions:DescribePlayerSessionsResponse' :: DescribePlayerSessionsResponse -> Maybe [PlayerSession]
playerSessions} -> Maybe [PlayerSession]
playerSessions) (\s :: DescribePlayerSessionsResponse
s@DescribePlayerSessionsResponse' {} Maybe [PlayerSession]
a -> DescribePlayerSessionsResponse
s {$sel:playerSessions:DescribePlayerSessionsResponse' :: Maybe [PlayerSession]
playerSessions = Maybe [PlayerSession]
a} :: DescribePlayerSessionsResponse) ((Maybe [PlayerSession] -> f (Maybe [PlayerSession]))
 -> DescribePlayerSessionsResponse
 -> f DescribePlayerSessionsResponse)
-> ((Maybe [PlayerSession] -> f (Maybe [PlayerSession]))
    -> Maybe [PlayerSession] -> f (Maybe [PlayerSession]))
-> (Maybe [PlayerSession] -> f (Maybe [PlayerSession]))
-> DescribePlayerSessionsResponse
-> f DescribePlayerSessionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PlayerSession] [PlayerSession] [PlayerSession] [PlayerSession]
-> Iso
     (Maybe [PlayerSession])
     (Maybe [PlayerSession])
     (Maybe [PlayerSession])
     (Maybe [PlayerSession])
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
  [PlayerSession] [PlayerSession] [PlayerSession] [PlayerSession]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribePlayerSessionsResponse