{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.GameServerInstance
-- 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)
module Amazonka.GameLift.Types.GameServerInstance where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types.GameServerInstanceStatus
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | __This data type is used with the GameLift FleetIQ and game server
-- groups.__
--
-- Additional properties, including status, that describe an EC2 instance
-- in a game server group. Instance configurations are set with game server
-- group properties (see @DescribeGameServerGroup@ and with the EC2 launch
-- template that was used when creating the game server group.
--
-- Retrieve game server instances for a game server group by calling
-- @DescribeGameServerInstances@.
--
-- __Related actions__
--
-- CreateGameServerGroup | ListGameServerGroups | DescribeGameServerGroup |
-- UpdateGameServerGroup | DeleteGameServerGroup | ResumeGameServerGroup |
-- SuspendGameServerGroup | DescribeGameServerInstances |
-- <https://docs.aws.amazon.com/gamelift/latest/fleetiqguide/reference-awssdk-fleetiq.html All APIs by task>
--
-- /See:/ 'newGameServerInstance' smart constructor.
data GameServerInstance = GameServerInstance'
  { -- | The unique identifier for the instance where the game server is running.
    -- This ID is available in the instance metadata. EC2 instance IDs use a
    -- 17-character format, for example: @i-1234567890abcdef0@.
    GameServerInstance -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | A developer-defined identifier for the game server group that includes
    -- the game server instance. The name is unique for each Region in each AWS
    -- account.
    GameServerInstance -> Maybe Text
gameServerGroupName :: Prelude.Maybe Prelude.Text,
    -- | Current status of the game server instance.
    --
    -- -   __ACTIVE__ -- The instance is viable for hosting game servers.
    --
    -- -   __DRAINING__ -- The instance is not viable for hosting game servers.
    --     Existing game servers are in the process of ending, and new game
    --     servers are not started on this instance unless no other resources
    --     are available. When the instance is put in DRAINING, a new instance
    --     is started up to replace it. Once the instance has no UTILIZED game
    --     servers, it will be terminated in favor of the new instance.
    --
    -- -   __SPOT_TERMINATING__ -- The instance is in the process of shutting
    --     down due to a Spot instance interruption. No new game servers are
    --     started on this instance.
    GameServerInstance -> Maybe GameServerInstanceStatus
instanceStatus :: Prelude.Maybe GameServerInstanceStatus,
    -- | A generated unique identifier for the game server group that includes
    -- the game server instance.
    GameServerInstance -> Maybe Text
gameServerGroupArn :: Prelude.Maybe Prelude.Text
  }
  deriving (GameServerInstance -> GameServerInstance -> Bool
(GameServerInstance -> GameServerInstance -> Bool)
-> (GameServerInstance -> GameServerInstance -> Bool)
-> Eq GameServerInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GameServerInstance -> GameServerInstance -> Bool
$c/= :: GameServerInstance -> GameServerInstance -> Bool
== :: GameServerInstance -> GameServerInstance -> Bool
$c== :: GameServerInstance -> GameServerInstance -> Bool
Prelude.Eq, ReadPrec [GameServerInstance]
ReadPrec GameServerInstance
Int -> ReadS GameServerInstance
ReadS [GameServerInstance]
(Int -> ReadS GameServerInstance)
-> ReadS [GameServerInstance]
-> ReadPrec GameServerInstance
-> ReadPrec [GameServerInstance]
-> Read GameServerInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GameServerInstance]
$creadListPrec :: ReadPrec [GameServerInstance]
readPrec :: ReadPrec GameServerInstance
$creadPrec :: ReadPrec GameServerInstance
readList :: ReadS [GameServerInstance]
$creadList :: ReadS [GameServerInstance]
readsPrec :: Int -> ReadS GameServerInstance
$creadsPrec :: Int -> ReadS GameServerInstance
Prelude.Read, Int -> GameServerInstance -> ShowS
[GameServerInstance] -> ShowS
GameServerInstance -> String
(Int -> GameServerInstance -> ShowS)
-> (GameServerInstance -> String)
-> ([GameServerInstance] -> ShowS)
-> Show GameServerInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GameServerInstance] -> ShowS
$cshowList :: [GameServerInstance] -> ShowS
show :: GameServerInstance -> String
$cshow :: GameServerInstance -> String
showsPrec :: Int -> GameServerInstance -> ShowS
$cshowsPrec :: Int -> GameServerInstance -> ShowS
Prelude.Show, (forall x. GameServerInstance -> Rep GameServerInstance x)
-> (forall x. Rep GameServerInstance x -> GameServerInstance)
-> Generic GameServerInstance
forall x. Rep GameServerInstance x -> GameServerInstance
forall x. GameServerInstance -> Rep GameServerInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GameServerInstance x -> GameServerInstance
$cfrom :: forall x. GameServerInstance -> Rep GameServerInstance x
Prelude.Generic)

-- |
-- Create a value of 'GameServerInstance' 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:
--
-- 'instanceId', 'gameServerInstance_instanceId' - The unique identifier for the instance where the game server is running.
-- This ID is available in the instance metadata. EC2 instance IDs use a
-- 17-character format, for example: @i-1234567890abcdef0@.
--
-- 'gameServerGroupName', 'gameServerInstance_gameServerGroupName' - A developer-defined identifier for the game server group that includes
-- the game server instance. The name is unique for each Region in each AWS
-- account.
--
-- 'instanceStatus', 'gameServerInstance_instanceStatus' - Current status of the game server instance.
--
-- -   __ACTIVE__ -- The instance is viable for hosting game servers.
--
-- -   __DRAINING__ -- The instance is not viable for hosting game servers.
--     Existing game servers are in the process of ending, and new game
--     servers are not started on this instance unless no other resources
--     are available. When the instance is put in DRAINING, a new instance
--     is started up to replace it. Once the instance has no UTILIZED game
--     servers, it will be terminated in favor of the new instance.
--
-- -   __SPOT_TERMINATING__ -- The instance is in the process of shutting
--     down due to a Spot instance interruption. No new game servers are
--     started on this instance.
--
-- 'gameServerGroupArn', 'gameServerInstance_gameServerGroupArn' - A generated unique identifier for the game server group that includes
-- the game server instance.
newGameServerInstance ::
  GameServerInstance
newGameServerInstance :: GameServerInstance
newGameServerInstance =
  GameServerInstance' :: Maybe Text
-> Maybe Text
-> Maybe GameServerInstanceStatus
-> Maybe Text
-> GameServerInstance
GameServerInstance'
    { $sel:instanceId:GameServerInstance' :: Maybe Text
instanceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:gameServerGroupName:GameServerInstance' :: Maybe Text
gameServerGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceStatus:GameServerInstance' :: Maybe GameServerInstanceStatus
instanceStatus = Maybe GameServerInstanceStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:gameServerGroupArn:GameServerInstance' :: Maybe Text
gameServerGroupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the instance where the game server is running.
-- This ID is available in the instance metadata. EC2 instance IDs use a
-- 17-character format, for example: @i-1234567890abcdef0@.
gameServerInstance_instanceId :: Lens.Lens' GameServerInstance (Prelude.Maybe Prelude.Text)
gameServerInstance_instanceId :: (Maybe Text -> f (Maybe Text))
-> GameServerInstance -> f GameServerInstance
gameServerInstance_instanceId = (GameServerInstance -> Maybe Text)
-> (GameServerInstance -> Maybe Text -> GameServerInstance)
-> Lens
     GameServerInstance GameServerInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameServerInstance' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:GameServerInstance' :: GameServerInstance -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: GameServerInstance
s@GameServerInstance' {} Maybe Text
a -> GameServerInstance
s {$sel:instanceId:GameServerInstance' :: Maybe Text
instanceId = Maybe Text
a} :: GameServerInstance)

-- | A developer-defined identifier for the game server group that includes
-- the game server instance. The name is unique for each Region in each AWS
-- account.
gameServerInstance_gameServerGroupName :: Lens.Lens' GameServerInstance (Prelude.Maybe Prelude.Text)
gameServerInstance_gameServerGroupName :: (Maybe Text -> f (Maybe Text))
-> GameServerInstance -> f GameServerInstance
gameServerInstance_gameServerGroupName = (GameServerInstance -> Maybe Text)
-> (GameServerInstance -> Maybe Text -> GameServerInstance)
-> Lens
     GameServerInstance GameServerInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameServerInstance' {Maybe Text
gameServerGroupName :: Maybe Text
$sel:gameServerGroupName:GameServerInstance' :: GameServerInstance -> Maybe Text
gameServerGroupName} -> Maybe Text
gameServerGroupName) (\s :: GameServerInstance
s@GameServerInstance' {} Maybe Text
a -> GameServerInstance
s {$sel:gameServerGroupName:GameServerInstance' :: Maybe Text
gameServerGroupName = Maybe Text
a} :: GameServerInstance)

-- | Current status of the game server instance.
--
-- -   __ACTIVE__ -- The instance is viable for hosting game servers.
--
-- -   __DRAINING__ -- The instance is not viable for hosting game servers.
--     Existing game servers are in the process of ending, and new game
--     servers are not started on this instance unless no other resources
--     are available. When the instance is put in DRAINING, a new instance
--     is started up to replace it. Once the instance has no UTILIZED game
--     servers, it will be terminated in favor of the new instance.
--
-- -   __SPOT_TERMINATING__ -- The instance is in the process of shutting
--     down due to a Spot instance interruption. No new game servers are
--     started on this instance.
gameServerInstance_instanceStatus :: Lens.Lens' GameServerInstance (Prelude.Maybe GameServerInstanceStatus)
gameServerInstance_instanceStatus :: (Maybe GameServerInstanceStatus
 -> f (Maybe GameServerInstanceStatus))
-> GameServerInstance -> f GameServerInstance
gameServerInstance_instanceStatus = (GameServerInstance -> Maybe GameServerInstanceStatus)
-> (GameServerInstance
    -> Maybe GameServerInstanceStatus -> GameServerInstance)
-> Lens
     GameServerInstance
     GameServerInstance
     (Maybe GameServerInstanceStatus)
     (Maybe GameServerInstanceStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameServerInstance' {Maybe GameServerInstanceStatus
instanceStatus :: Maybe GameServerInstanceStatus
$sel:instanceStatus:GameServerInstance' :: GameServerInstance -> Maybe GameServerInstanceStatus
instanceStatus} -> Maybe GameServerInstanceStatus
instanceStatus) (\s :: GameServerInstance
s@GameServerInstance' {} Maybe GameServerInstanceStatus
a -> GameServerInstance
s {$sel:instanceStatus:GameServerInstance' :: Maybe GameServerInstanceStatus
instanceStatus = Maybe GameServerInstanceStatus
a} :: GameServerInstance)

-- | A generated unique identifier for the game server group that includes
-- the game server instance.
gameServerInstance_gameServerGroupArn :: Lens.Lens' GameServerInstance (Prelude.Maybe Prelude.Text)
gameServerInstance_gameServerGroupArn :: (Maybe Text -> f (Maybe Text))
-> GameServerInstance -> f GameServerInstance
gameServerInstance_gameServerGroupArn = (GameServerInstance -> Maybe Text)
-> (GameServerInstance -> Maybe Text -> GameServerInstance)
-> Lens
     GameServerInstance GameServerInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameServerInstance' {Maybe Text
gameServerGroupArn :: Maybe Text
$sel:gameServerGroupArn:GameServerInstance' :: GameServerInstance -> Maybe Text
gameServerGroupArn} -> Maybe Text
gameServerGroupArn) (\s :: GameServerInstance
s@GameServerInstance' {} Maybe Text
a -> GameServerInstance
s {$sel:gameServerGroupArn:GameServerInstance' :: Maybe Text
gameServerGroupArn = Maybe Text
a} :: GameServerInstance)

instance Core.FromJSON GameServerInstance where
  parseJSON :: Value -> Parser GameServerInstance
parseJSON =
    String
-> (Object -> Parser GameServerInstance)
-> Value
-> Parser GameServerInstance
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GameServerInstance"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe GameServerInstanceStatus
-> Maybe Text
-> GameServerInstance
GameServerInstance'
            (Maybe Text
 -> Maybe Text
 -> Maybe GameServerInstanceStatus
 -> Maybe Text
 -> GameServerInstance)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe GameServerInstanceStatus
      -> Maybe Text
      -> GameServerInstance)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InstanceId")
            Parser
  (Maybe Text
   -> Maybe GameServerInstanceStatus
   -> Maybe Text
   -> GameServerInstance)
-> Parser (Maybe Text)
-> Parser
     (Maybe GameServerInstanceStatus
      -> Maybe Text -> GameServerInstance)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GameServerGroupName")
            Parser
  (Maybe GameServerInstanceStatus
   -> Maybe Text -> GameServerInstance)
-> Parser (Maybe GameServerInstanceStatus)
-> Parser (Maybe Text -> GameServerInstance)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe GameServerInstanceStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InstanceStatus")
            Parser (Maybe Text -> GameServerInstance)
-> Parser (Maybe Text) -> Parser GameServerInstance
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GameServerGroupArn")
      )

instance Prelude.Hashable GameServerInstance

instance Prelude.NFData GameServerInstance