{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GameLift.Types.GameServerInstance where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GameLift.Types.GameServerInstanceStatus
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@.
--
-- /See:/ 'newGameServerInstance' smart constructor.
data GameServerInstance = GameServerInstance'
  { -- | A generated unique identifier for the game server group that includes
    -- the game server instance.
    GameServerInstance -> Maybe Text
gameServerGroupArn :: 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
    -- Amazon Web Services account.
    GameServerInstance -> Maybe Text
gameServerGroupName :: Prelude.Maybe Prelude.Text,
    -- | 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,
    -- | Current status of the game server instance
    GameServerInstance -> Maybe GameServerInstanceStatus
instanceStatus :: Prelude.Maybe GameServerInstanceStatus
  }
  deriving (GameServerInstance -> GameServerInstance -> Bool
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]
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
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. 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:
--
-- 'gameServerGroupArn', 'gameServerInstance_gameServerGroupArn' - A generated unique identifier for the game server group that includes
-- the game server instance.
--
-- '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
-- Amazon Web Services account.
--
-- '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@.
--
-- 'instanceStatus', 'gameServerInstance_instanceStatus' - Current status of the game server instance
newGameServerInstance ::
  GameServerInstance
newGameServerInstance :: GameServerInstance
newGameServerInstance =
  GameServerInstance'
    { $sel:gameServerGroupArn:GameServerInstance' :: Maybe Text
gameServerGroupArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:gameServerGroupName:GameServerInstance' :: Maybe Text
gameServerGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:GameServerInstance' :: Maybe Text
instanceId = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceStatus:GameServerInstance' :: Maybe GameServerInstanceStatus
instanceStatus = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' GameServerInstance (Maybe Text)
gameServerInstance_gameServerGroupArn = 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)

-- | A developer-defined identifier for the game server group that includes
-- the game server instance. The name is unique for each Region in each
-- Amazon Web Services account.
gameServerInstance_gameServerGroupName :: Lens.Lens' GameServerInstance (Prelude.Maybe Prelude.Text)
gameServerInstance_gameServerGroupName :: Lens' GameServerInstance (Maybe Text)
gameServerInstance_gameServerGroupName = 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)

-- | 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 :: Lens' GameServerInstance (Maybe Text)
gameServerInstance_instanceId = 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)

-- | Current status of the game server instance
gameServerInstance_instanceStatus :: Lens.Lens' GameServerInstance (Prelude.Maybe GameServerInstanceStatus)
gameServerInstance_instanceStatus :: Lens' GameServerInstance (Maybe GameServerInstanceStatus)
gameServerInstance_instanceStatus = 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)

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

instance Prelude.Hashable GameServerInstance where
  hashWithSalt :: Int -> GameServerInstance -> Int
hashWithSalt Int
_salt GameServerInstance' {Maybe Text
Maybe GameServerInstanceStatus
instanceStatus :: Maybe GameServerInstanceStatus
instanceId :: Maybe Text
gameServerGroupName :: Maybe Text
gameServerGroupArn :: Maybe Text
$sel:instanceStatus:GameServerInstance' :: GameServerInstance -> Maybe GameServerInstanceStatus
$sel:instanceId:GameServerInstance' :: GameServerInstance -> Maybe Text
$sel:gameServerGroupName:GameServerInstance' :: GameServerInstance -> Maybe Text
$sel:gameServerGroupArn:GameServerInstance' :: GameServerInstance -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
gameServerGroupArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
gameServerGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GameServerInstanceStatus
instanceStatus

instance Prelude.NFData GameServerInstance where
  rnf :: GameServerInstance -> ()
rnf GameServerInstance' {Maybe Text
Maybe GameServerInstanceStatus
instanceStatus :: Maybe GameServerInstanceStatus
instanceId :: Maybe Text
gameServerGroupName :: Maybe Text
gameServerGroupArn :: Maybe Text
$sel:instanceStatus:GameServerInstance' :: GameServerInstance -> Maybe GameServerInstanceStatus
$sel:instanceId:GameServerInstance' :: GameServerInstance -> Maybe Text
$sel:gameServerGroupName:GameServerInstance' :: GameServerInstance -> Maybe Text
$sel:gameServerGroupArn:GameServerInstance' :: GameServerInstance -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
gameServerGroupArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
gameServerGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe GameServerInstanceStatus
instanceStatus