{-# 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.DescribeGameServer
-- 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 information for a registered game server. Information includes
-- game server status, health check info, and the instance that the game
-- server is running on.
--
-- To retrieve game server information, specify the game server ID. If
-- successful, the requested game server object is returned.
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/gsg-intro.html GameLift FleetIQ Guide>
--
-- __Related actions__
--
-- RegisterGameServer | ListGameServers | ClaimGameServer |
-- DescribeGameServer | UpdateGameServer | DeregisterGameServer |
-- <https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/reference-awssdk-fleetiq.html All APIs by task>
module Amazonka.GameLift.DescribeGameServer
  ( -- * Creating a Request
    DescribeGameServer (..),
    newDescribeGameServer,

    -- * Request Lenses
    describeGameServer_gameServerGroupName,
    describeGameServer_gameServerId,

    -- * Destructuring the Response
    DescribeGameServerResponse (..),
    newDescribeGameServerResponse,

    -- * Response Lenses
    describeGameServerResponse_gameServer,
    describeGameServerResponse_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:/ 'newDescribeGameServer' smart constructor.
data DescribeGameServer = DescribeGameServer'
  { -- | A unique identifier for the game server group where the game server is
    -- running. Use either the GameServerGroup name or ARN value.
    DescribeGameServer -> Text
gameServerGroupName :: Prelude.Text,
    -- | A custom string that uniquely identifies the game server information to
    -- be retrieved.
    DescribeGameServer -> Text
gameServerId :: Prelude.Text
  }
  deriving (DescribeGameServer -> DescribeGameServer -> Bool
(DescribeGameServer -> DescribeGameServer -> Bool)
-> (DescribeGameServer -> DescribeGameServer -> Bool)
-> Eq DescribeGameServer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGameServer -> DescribeGameServer -> Bool
$c/= :: DescribeGameServer -> DescribeGameServer -> Bool
== :: DescribeGameServer -> DescribeGameServer -> Bool
$c== :: DescribeGameServer -> DescribeGameServer -> Bool
Prelude.Eq, ReadPrec [DescribeGameServer]
ReadPrec DescribeGameServer
Int -> ReadS DescribeGameServer
ReadS [DescribeGameServer]
(Int -> ReadS DescribeGameServer)
-> ReadS [DescribeGameServer]
-> ReadPrec DescribeGameServer
-> ReadPrec [DescribeGameServer]
-> Read DescribeGameServer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGameServer]
$creadListPrec :: ReadPrec [DescribeGameServer]
readPrec :: ReadPrec DescribeGameServer
$creadPrec :: ReadPrec DescribeGameServer
readList :: ReadS [DescribeGameServer]
$creadList :: ReadS [DescribeGameServer]
readsPrec :: Int -> ReadS DescribeGameServer
$creadsPrec :: Int -> ReadS DescribeGameServer
Prelude.Read, Int -> DescribeGameServer -> ShowS
[DescribeGameServer] -> ShowS
DescribeGameServer -> String
(Int -> DescribeGameServer -> ShowS)
-> (DescribeGameServer -> String)
-> ([DescribeGameServer] -> ShowS)
-> Show DescribeGameServer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGameServer] -> ShowS
$cshowList :: [DescribeGameServer] -> ShowS
show :: DescribeGameServer -> String
$cshow :: DescribeGameServer -> String
showsPrec :: Int -> DescribeGameServer -> ShowS
$cshowsPrec :: Int -> DescribeGameServer -> ShowS
Prelude.Show, (forall x. DescribeGameServer -> Rep DescribeGameServer x)
-> (forall x. Rep DescribeGameServer x -> DescribeGameServer)
-> Generic DescribeGameServer
forall x. Rep DescribeGameServer x -> DescribeGameServer
forall x. DescribeGameServer -> Rep DescribeGameServer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeGameServer x -> DescribeGameServer
$cfrom :: forall x. DescribeGameServer -> Rep DescribeGameServer x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGameServer' 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:
--
-- 'gameServerGroupName', 'describeGameServer_gameServerGroupName' - A unique identifier for the game server group where the game server is
-- running. Use either the GameServerGroup name or ARN value.
--
-- 'gameServerId', 'describeGameServer_gameServerId' - A custom string that uniquely identifies the game server information to
-- be retrieved.
newDescribeGameServer ::
  -- | 'gameServerGroupName'
  Prelude.Text ->
  -- | 'gameServerId'
  Prelude.Text ->
  DescribeGameServer
newDescribeGameServer :: Text -> Text -> DescribeGameServer
newDescribeGameServer
  Text
pGameServerGroupName_
  Text
pGameServerId_ =
    DescribeGameServer' :: Text -> Text -> DescribeGameServer
DescribeGameServer'
      { $sel:gameServerGroupName:DescribeGameServer' :: Text
gameServerGroupName =
          Text
pGameServerGroupName_,
        $sel:gameServerId:DescribeGameServer' :: Text
gameServerId = Text
pGameServerId_
      }

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

-- | A custom string that uniquely identifies the game server information to
-- be retrieved.
describeGameServer_gameServerId :: Lens.Lens' DescribeGameServer Prelude.Text
describeGameServer_gameServerId :: (Text -> f Text) -> DescribeGameServer -> f DescribeGameServer
describeGameServer_gameServerId = (DescribeGameServer -> Text)
-> (DescribeGameServer -> Text -> DescribeGameServer)
-> Lens DescribeGameServer DescribeGameServer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameServer' {Text
gameServerId :: Text
$sel:gameServerId:DescribeGameServer' :: DescribeGameServer -> Text
gameServerId} -> Text
gameServerId) (\s :: DescribeGameServer
s@DescribeGameServer' {} Text
a -> DescribeGameServer
s {$sel:gameServerId:DescribeGameServer' :: Text
gameServerId = Text
a} :: DescribeGameServer)

instance Core.AWSRequest DescribeGameServer where
  type
    AWSResponse DescribeGameServer =
      DescribeGameServerResponse
  request :: DescribeGameServer -> Request DescribeGameServer
request = Service -> DescribeGameServer -> Request DescribeGameServer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeGameServer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeGameServer)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeGameServer))
-> Logger
-> Service
-> Proxy DescribeGameServer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeGameServer)))
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 GameServer -> Int -> DescribeGameServerResponse
DescribeGameServerResponse'
            (Maybe GameServer -> Int -> DescribeGameServerResponse)
-> Either String (Maybe GameServer)
-> Either String (Int -> DescribeGameServerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GameServer)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GameServer")
            Either String (Int -> DescribeGameServerResponse)
-> Either String Int -> Either String DescribeGameServerResponse
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 DescribeGameServer

instance Prelude.NFData DescribeGameServer

instance Core.ToHeaders DescribeGameServer where
  toHeaders :: DescribeGameServer -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeGameServer -> 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.DescribeGameServer" ::
                          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 DescribeGameServer where
  toJSON :: DescribeGameServer -> Value
toJSON DescribeGameServer' {Text
gameServerId :: Text
gameServerGroupName :: Text
$sel:gameServerId:DescribeGameServer' :: DescribeGameServer -> Text
$sel:gameServerGroupName:DescribeGameServer' :: DescribeGameServer -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GameServerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gameServerId)
          ]
      )

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

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

-- | /See:/ 'newDescribeGameServerResponse' smart constructor.
data DescribeGameServerResponse = DescribeGameServerResponse'
  { -- | Object that describes the requested game server.
    DescribeGameServerResponse -> Maybe GameServer
gameServer :: Prelude.Maybe GameServer,
    -- | The response's http status code.
    DescribeGameServerResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeGameServerResponse -> DescribeGameServerResponse -> Bool
(DescribeGameServerResponse -> DescribeGameServerResponse -> Bool)
-> (DescribeGameServerResponse
    -> DescribeGameServerResponse -> Bool)
-> Eq DescribeGameServerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGameServerResponse -> DescribeGameServerResponse -> Bool
$c/= :: DescribeGameServerResponse -> DescribeGameServerResponse -> Bool
== :: DescribeGameServerResponse -> DescribeGameServerResponse -> Bool
$c== :: DescribeGameServerResponse -> DescribeGameServerResponse -> Bool
Prelude.Eq, ReadPrec [DescribeGameServerResponse]
ReadPrec DescribeGameServerResponse
Int -> ReadS DescribeGameServerResponse
ReadS [DescribeGameServerResponse]
(Int -> ReadS DescribeGameServerResponse)
-> ReadS [DescribeGameServerResponse]
-> ReadPrec DescribeGameServerResponse
-> ReadPrec [DescribeGameServerResponse]
-> Read DescribeGameServerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGameServerResponse]
$creadListPrec :: ReadPrec [DescribeGameServerResponse]
readPrec :: ReadPrec DescribeGameServerResponse
$creadPrec :: ReadPrec DescribeGameServerResponse
readList :: ReadS [DescribeGameServerResponse]
$creadList :: ReadS [DescribeGameServerResponse]
readsPrec :: Int -> ReadS DescribeGameServerResponse
$creadsPrec :: Int -> ReadS DescribeGameServerResponse
Prelude.Read, Int -> DescribeGameServerResponse -> ShowS
[DescribeGameServerResponse] -> ShowS
DescribeGameServerResponse -> String
(Int -> DescribeGameServerResponse -> ShowS)
-> (DescribeGameServerResponse -> String)
-> ([DescribeGameServerResponse] -> ShowS)
-> Show DescribeGameServerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGameServerResponse] -> ShowS
$cshowList :: [DescribeGameServerResponse] -> ShowS
show :: DescribeGameServerResponse -> String
$cshow :: DescribeGameServerResponse -> String
showsPrec :: Int -> DescribeGameServerResponse -> ShowS
$cshowsPrec :: Int -> DescribeGameServerResponse -> ShowS
Prelude.Show, (forall x.
 DescribeGameServerResponse -> Rep DescribeGameServerResponse x)
-> (forall x.
    Rep DescribeGameServerResponse x -> DescribeGameServerResponse)
-> Generic DescribeGameServerResponse
forall x.
Rep DescribeGameServerResponse x -> DescribeGameServerResponse
forall x.
DescribeGameServerResponse -> Rep DescribeGameServerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeGameServerResponse x -> DescribeGameServerResponse
$cfrom :: forall x.
DescribeGameServerResponse -> Rep DescribeGameServerResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGameServerResponse' 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:
--
-- 'gameServer', 'describeGameServerResponse_gameServer' - Object that describes the requested game server.
--
-- 'httpStatus', 'describeGameServerResponse_httpStatus' - The response's http status code.
newDescribeGameServerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeGameServerResponse
newDescribeGameServerResponse :: Int -> DescribeGameServerResponse
newDescribeGameServerResponse Int
pHttpStatus_ =
  DescribeGameServerResponse' :: Maybe GameServer -> Int -> DescribeGameServerResponse
DescribeGameServerResponse'
    { $sel:gameServer:DescribeGameServerResponse' :: Maybe GameServer
gameServer =
        Maybe GameServer
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeGameServerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Object that describes the requested game server.
describeGameServerResponse_gameServer :: Lens.Lens' DescribeGameServerResponse (Prelude.Maybe GameServer)
describeGameServerResponse_gameServer :: (Maybe GameServer -> f (Maybe GameServer))
-> DescribeGameServerResponse -> f DescribeGameServerResponse
describeGameServerResponse_gameServer = (DescribeGameServerResponse -> Maybe GameServer)
-> (DescribeGameServerResponse
    -> Maybe GameServer -> DescribeGameServerResponse)
-> Lens
     DescribeGameServerResponse
     DescribeGameServerResponse
     (Maybe GameServer)
     (Maybe GameServer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameServerResponse' {Maybe GameServer
gameServer :: Maybe GameServer
$sel:gameServer:DescribeGameServerResponse' :: DescribeGameServerResponse -> Maybe GameServer
gameServer} -> Maybe GameServer
gameServer) (\s :: DescribeGameServerResponse
s@DescribeGameServerResponse' {} Maybe GameServer
a -> DescribeGameServerResponse
s {$sel:gameServer:DescribeGameServerResponse' :: Maybe GameServer
gameServer = Maybe GameServer
a} :: DescribeGameServerResponse)

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

instance Prelude.NFData DescribeGameServerResponse