{-# 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.GameSessionDetail
-- 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.GameSessionDetail 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.GameSession
import Amazonka.GameLift.Types.ProtectionPolicy
import qualified Amazonka.Prelude as Prelude

-- | A game session\'s properties plus the protection policy currently in
-- force.
--
-- /See:/ 'newGameSessionDetail' smart constructor.
data GameSessionDetail = GameSessionDetail'
  { -- | Object that describes a game session.
    GameSessionDetail -> Maybe GameSession
gameSession :: Prelude.Maybe GameSession,
    -- | Current status of protection for the game session.
    --
    -- -   __NoProtection__ -- The game session can be terminated during a
    --     scale-down event.
    --
    -- -   __FullProtection__ -- If the game session is in an @ACTIVE@ status,
    --     it cannot be terminated during a scale-down event.
    GameSessionDetail -> Maybe ProtectionPolicy
protectionPolicy :: Prelude.Maybe ProtectionPolicy
  }
  deriving (GameSessionDetail -> GameSessionDetail -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GameSessionDetail -> GameSessionDetail -> Bool
$c/= :: GameSessionDetail -> GameSessionDetail -> Bool
== :: GameSessionDetail -> GameSessionDetail -> Bool
$c== :: GameSessionDetail -> GameSessionDetail -> Bool
Prelude.Eq, ReadPrec [GameSessionDetail]
ReadPrec GameSessionDetail
Int -> ReadS GameSessionDetail
ReadS [GameSessionDetail]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GameSessionDetail]
$creadListPrec :: ReadPrec [GameSessionDetail]
readPrec :: ReadPrec GameSessionDetail
$creadPrec :: ReadPrec GameSessionDetail
readList :: ReadS [GameSessionDetail]
$creadList :: ReadS [GameSessionDetail]
readsPrec :: Int -> ReadS GameSessionDetail
$creadsPrec :: Int -> ReadS GameSessionDetail
Prelude.Read, Int -> GameSessionDetail -> ShowS
[GameSessionDetail] -> ShowS
GameSessionDetail -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GameSessionDetail] -> ShowS
$cshowList :: [GameSessionDetail] -> ShowS
show :: GameSessionDetail -> String
$cshow :: GameSessionDetail -> String
showsPrec :: Int -> GameSessionDetail -> ShowS
$cshowsPrec :: Int -> GameSessionDetail -> ShowS
Prelude.Show, forall x. Rep GameSessionDetail x -> GameSessionDetail
forall x. GameSessionDetail -> Rep GameSessionDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GameSessionDetail x -> GameSessionDetail
$cfrom :: forall x. GameSessionDetail -> Rep GameSessionDetail x
Prelude.Generic)

-- |
-- Create a value of 'GameSessionDetail' 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:
--
-- 'gameSession', 'gameSessionDetail_gameSession' - Object that describes a game session.
--
-- 'protectionPolicy', 'gameSessionDetail_protectionPolicy' - Current status of protection for the game session.
--
-- -   __NoProtection__ -- The game session can be terminated during a
--     scale-down event.
--
-- -   __FullProtection__ -- If the game session is in an @ACTIVE@ status,
--     it cannot be terminated during a scale-down event.
newGameSessionDetail ::
  GameSessionDetail
newGameSessionDetail :: GameSessionDetail
newGameSessionDetail =
  GameSessionDetail'
    { $sel:gameSession:GameSessionDetail' :: Maybe GameSession
gameSession = forall a. Maybe a
Prelude.Nothing,
      $sel:protectionPolicy:GameSessionDetail' :: Maybe ProtectionPolicy
protectionPolicy = forall a. Maybe a
Prelude.Nothing
    }

-- | Object that describes a game session.
gameSessionDetail_gameSession :: Lens.Lens' GameSessionDetail (Prelude.Maybe GameSession)
gameSessionDetail_gameSession :: Lens' GameSessionDetail (Maybe GameSession)
gameSessionDetail_gameSession = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameSessionDetail' {Maybe GameSession
gameSession :: Maybe GameSession
$sel:gameSession:GameSessionDetail' :: GameSessionDetail -> Maybe GameSession
gameSession} -> Maybe GameSession
gameSession) (\s :: GameSessionDetail
s@GameSessionDetail' {} Maybe GameSession
a -> GameSessionDetail
s {$sel:gameSession:GameSessionDetail' :: Maybe GameSession
gameSession = Maybe GameSession
a} :: GameSessionDetail)

-- | Current status of protection for the game session.
--
-- -   __NoProtection__ -- The game session can be terminated during a
--     scale-down event.
--
-- -   __FullProtection__ -- If the game session is in an @ACTIVE@ status,
--     it cannot be terminated during a scale-down event.
gameSessionDetail_protectionPolicy :: Lens.Lens' GameSessionDetail (Prelude.Maybe ProtectionPolicy)
gameSessionDetail_protectionPolicy :: Lens' GameSessionDetail (Maybe ProtectionPolicy)
gameSessionDetail_protectionPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GameSessionDetail' {Maybe ProtectionPolicy
protectionPolicy :: Maybe ProtectionPolicy
$sel:protectionPolicy:GameSessionDetail' :: GameSessionDetail -> Maybe ProtectionPolicy
protectionPolicy} -> Maybe ProtectionPolicy
protectionPolicy) (\s :: GameSessionDetail
s@GameSessionDetail' {} Maybe ProtectionPolicy
a -> GameSessionDetail
s {$sel:protectionPolicy:GameSessionDetail' :: Maybe ProtectionPolicy
protectionPolicy = Maybe ProtectionPolicy
a} :: GameSessionDetail)

instance Data.FromJSON GameSessionDetail where
  parseJSON :: Value -> Parser GameSessionDetail
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GameSessionDetail"
      ( \Object
x ->
          Maybe GameSession -> Maybe ProtectionPolicy -> GameSessionDetail
GameSessionDetail'
            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
"GameSession")
            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
"ProtectionPolicy")
      )

instance Prelude.Hashable GameSessionDetail where
  hashWithSalt :: Int -> GameSessionDetail -> Int
hashWithSalt Int
_salt GameSessionDetail' {Maybe GameSession
Maybe ProtectionPolicy
protectionPolicy :: Maybe ProtectionPolicy
gameSession :: Maybe GameSession
$sel:protectionPolicy:GameSessionDetail' :: GameSessionDetail -> Maybe ProtectionPolicy
$sel:gameSession:GameSessionDetail' :: GameSessionDetail -> Maybe GameSession
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GameSession
gameSession
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ProtectionPolicy
protectionPolicy

instance Prelude.NFData GameSessionDetail where
  rnf :: GameSessionDetail -> ()
rnf GameSessionDetail' {Maybe GameSession
Maybe ProtectionPolicy
protectionPolicy :: Maybe ProtectionPolicy
gameSession :: Maybe GameSession
$sel:protectionPolicy:GameSessionDetail' :: GameSessionDetail -> Maybe ProtectionPolicy
$sel:gameSession:GameSessionDetail' :: GameSessionDetail -> Maybe GameSession
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe GameSession
gameSession
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ProtectionPolicy
protectionPolicy