{-# 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-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.GameSessionDetail where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types.GameSession
import Amazonka.GameLift.Types.ProtectionPolicy
import qualified Amazonka.Lens as Lens
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
(GameSessionDetail -> GameSessionDetail -> Bool)
-> (GameSessionDetail -> GameSessionDetail -> Bool)
-> Eq GameSessionDetail
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]
(Int -> ReadS GameSessionDetail)
-> ReadS [GameSessionDetail]
-> ReadPrec GameSessionDetail
-> ReadPrec [GameSessionDetail]
-> Read 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
(Int -> GameSessionDetail -> ShowS)
-> (GameSessionDetail -> String)
-> ([GameSessionDetail] -> ShowS)
-> Show GameSessionDetail
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. GameSessionDetail -> Rep GameSessionDetail x)
-> (forall x. Rep GameSessionDetail x -> GameSessionDetail)
-> Generic GameSessionDetail
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' :: Maybe GameSession -> Maybe ProtectionPolicy -> GameSessionDetail
GameSessionDetail'
    { $sel:gameSession:GameSessionDetail' :: Maybe GameSession
gameSession = Maybe GameSession
forall a. Maybe a
Prelude.Nothing,
      $sel:protectionPolicy:GameSessionDetail' :: Maybe ProtectionPolicy
protectionPolicy = Maybe ProtectionPolicy
forall a. Maybe a
Prelude.Nothing
    }

-- | Object that describes a game session.
gameSessionDetail_gameSession :: Lens.Lens' GameSessionDetail (Prelude.Maybe GameSession)
gameSessionDetail_gameSession :: (Maybe GameSession -> f (Maybe GameSession))
-> GameSessionDetail -> f GameSessionDetail
gameSessionDetail_gameSession = (GameSessionDetail -> Maybe GameSession)
-> (GameSessionDetail -> Maybe GameSession -> GameSessionDetail)
-> Lens
     GameSessionDetail
     GameSessionDetail
     (Maybe GameSession)
     (Maybe 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 :: (Maybe ProtectionPolicy -> f (Maybe ProtectionPolicy))
-> GameSessionDetail -> f GameSessionDetail
gameSessionDetail_protectionPolicy = (GameSessionDetail -> Maybe ProtectionPolicy)
-> (GameSessionDetail
    -> Maybe ProtectionPolicy -> GameSessionDetail)
-> Lens
     GameSessionDetail
     GameSessionDetail
     (Maybe ProtectionPolicy)
     (Maybe 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 Core.FromJSON GameSessionDetail where
  parseJSON :: Value -> Parser GameSessionDetail
parseJSON =
    String
-> (Object -> Parser GameSessionDetail)
-> Value
-> Parser GameSessionDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GameSessionDetail"
      ( \Object
x ->
          Maybe GameSession -> Maybe ProtectionPolicy -> GameSessionDetail
GameSessionDetail'
            (Maybe GameSession -> Maybe ProtectionPolicy -> GameSessionDetail)
-> Parser (Maybe GameSession)
-> Parser (Maybe ProtectionPolicy -> GameSessionDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe GameSession)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GameSession")
            Parser (Maybe ProtectionPolicy -> GameSessionDetail)
-> Parser (Maybe ProtectionPolicy) -> Parser GameSessionDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ProtectionPolicy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProtectionPolicy")
      )

instance Prelude.Hashable GameSessionDetail

instance Prelude.NFData GameSessionDetail