{-# 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.DeregisterGameServer
-- 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.__
--
-- Removes the game server from a game server group. As a result of this
-- operation, the deregistered game server can no longer be claimed and
-- will not be returned in a list of active game servers.
--
-- To deregister a game server, specify the game server group and game
-- server ID. If successful, this operation emits a CloudWatch event with
-- termination timestamp and reason.
--
-- __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.DeregisterGameServer
  ( -- * Creating a Request
    DeregisterGameServer (..),
    newDeregisterGameServer,

    -- * Request Lenses
    deregisterGameServer_gameServerGroupName,
    deregisterGameServer_gameServerId,

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

-- |
-- Create a value of 'DeregisterGameServer' 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', 'deregisterGameServer_gameServerGroupName' - A unique identifier for the game server group where the game server is
-- running. Use either the GameServerGroup name or ARN value.
--
-- 'gameServerId', 'deregisterGameServer_gameServerId' - A custom string that uniquely identifies the game server to deregister.
newDeregisterGameServer ::
  -- | 'gameServerGroupName'
  Prelude.Text ->
  -- | 'gameServerId'
  Prelude.Text ->
  DeregisterGameServer
newDeregisterGameServer :: Text -> Text -> DeregisterGameServer
newDeregisterGameServer
  Text
pGameServerGroupName_
  Text
pGameServerId_ =
    DeregisterGameServer' :: Text -> Text -> DeregisterGameServer
DeregisterGameServer'
      { $sel:gameServerGroupName:DeregisterGameServer' :: Text
gameServerGroupName =
          Text
pGameServerGroupName_,
        $sel:gameServerId:DeregisterGameServer' :: 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.
deregisterGameServer_gameServerGroupName :: Lens.Lens' DeregisterGameServer Prelude.Text
deregisterGameServer_gameServerGroupName :: (Text -> f Text) -> DeregisterGameServer -> f DeregisterGameServer
deregisterGameServer_gameServerGroupName = (DeregisterGameServer -> Text)
-> (DeregisterGameServer -> Text -> DeregisterGameServer)
-> Lens DeregisterGameServer DeregisterGameServer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterGameServer' {Text
gameServerGroupName :: Text
$sel:gameServerGroupName:DeregisterGameServer' :: DeregisterGameServer -> Text
gameServerGroupName} -> Text
gameServerGroupName) (\s :: DeregisterGameServer
s@DeregisterGameServer' {} Text
a -> DeregisterGameServer
s {$sel:gameServerGroupName:DeregisterGameServer' :: Text
gameServerGroupName = Text
a} :: DeregisterGameServer)

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

instance Core.AWSRequest DeregisterGameServer where
  type
    AWSResponse DeregisterGameServer =
      DeregisterGameServerResponse
  request :: DeregisterGameServer -> Request DeregisterGameServer
request = Service -> DeregisterGameServer -> Request DeregisterGameServer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterGameServer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterGameServer)))
response =
    AWSResponse DeregisterGameServer
-> Logger
-> Service
-> Proxy DeregisterGameServer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterGameServer)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeregisterGameServer
DeregisterGameServerResponse
DeregisterGameServerResponse'

instance Prelude.Hashable DeregisterGameServer

instance Prelude.NFData DeregisterGameServer

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

instance Core.ToJSON DeregisterGameServer where
  toJSON :: DeregisterGameServer -> Value
toJSON DeregisterGameServer' {Text
gameServerId :: Text
gameServerGroupName :: Text
$sel:gameServerId:DeregisterGameServer' :: DeregisterGameServer -> Text
$sel:gameServerGroupName:DeregisterGameServer' :: DeregisterGameServer -> 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 DeregisterGameServer where
  toPath :: DeregisterGameServer -> ByteString
toPath = ByteString -> DeregisterGameServer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDeregisterGameServerResponse' smart constructor.
data DeregisterGameServerResponse = DeregisterGameServerResponse'
  {
  }
  deriving (DeregisterGameServerResponse
-> DeregisterGameServerResponse -> Bool
(DeregisterGameServerResponse
 -> DeregisterGameServerResponse -> Bool)
-> (DeregisterGameServerResponse
    -> DeregisterGameServerResponse -> Bool)
-> Eq DeregisterGameServerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterGameServerResponse
-> DeregisterGameServerResponse -> Bool
$c/= :: DeregisterGameServerResponse
-> DeregisterGameServerResponse -> Bool
== :: DeregisterGameServerResponse
-> DeregisterGameServerResponse -> Bool
$c== :: DeregisterGameServerResponse
-> DeregisterGameServerResponse -> Bool
Prelude.Eq, ReadPrec [DeregisterGameServerResponse]
ReadPrec DeregisterGameServerResponse
Int -> ReadS DeregisterGameServerResponse
ReadS [DeregisterGameServerResponse]
(Int -> ReadS DeregisterGameServerResponse)
-> ReadS [DeregisterGameServerResponse]
-> ReadPrec DeregisterGameServerResponse
-> ReadPrec [DeregisterGameServerResponse]
-> Read DeregisterGameServerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterGameServerResponse]
$creadListPrec :: ReadPrec [DeregisterGameServerResponse]
readPrec :: ReadPrec DeregisterGameServerResponse
$creadPrec :: ReadPrec DeregisterGameServerResponse
readList :: ReadS [DeregisterGameServerResponse]
$creadList :: ReadS [DeregisterGameServerResponse]
readsPrec :: Int -> ReadS DeregisterGameServerResponse
$creadsPrec :: Int -> ReadS DeregisterGameServerResponse
Prelude.Read, Int -> DeregisterGameServerResponse -> ShowS
[DeregisterGameServerResponse] -> ShowS
DeregisterGameServerResponse -> String
(Int -> DeregisterGameServerResponse -> ShowS)
-> (DeregisterGameServerResponse -> String)
-> ([DeregisterGameServerResponse] -> ShowS)
-> Show DeregisterGameServerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterGameServerResponse] -> ShowS
$cshowList :: [DeregisterGameServerResponse] -> ShowS
show :: DeregisterGameServerResponse -> String
$cshow :: DeregisterGameServerResponse -> String
showsPrec :: Int -> DeregisterGameServerResponse -> ShowS
$cshowsPrec :: Int -> DeregisterGameServerResponse -> ShowS
Prelude.Show, (forall x.
 DeregisterGameServerResponse -> Rep DeregisterGameServerResponse x)
-> (forall x.
    Rep DeregisterGameServerResponse x -> DeregisterGameServerResponse)
-> Generic DeregisterGameServerResponse
forall x.
Rep DeregisterGameServerResponse x -> DeregisterGameServerResponse
forall x.
DeregisterGameServerResponse -> Rep DeregisterGameServerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterGameServerResponse x -> DeregisterGameServerResponse
$cfrom :: forall x.
DeregisterGameServerResponse -> Rep DeregisterGameServerResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterGameServerResponse' 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.
newDeregisterGameServerResponse ::
  DeregisterGameServerResponse
newDeregisterGameServerResponse :: DeregisterGameServerResponse
newDeregisterGameServerResponse =
  DeregisterGameServerResponse
DeregisterGameServerResponse'

instance Prelude.NFData DeregisterGameServerResponse