{-# 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.LocationState
-- 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.LocationState 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.FleetStatus
import qualified Amazonka.Prelude as Prelude

-- | A fleet location and its life-cycle state. A location state object might
-- be used to describe a fleet\'s remote location or home Region.
-- Life-cycle state tracks the progress of launching the first instance in
-- a new location and preparing it for game hosting, and then removing all
-- instances and deleting the location from the fleet.
--
-- -   __NEW__ -- A new fleet location has been defined and desired
--     instances is set to 1.
--
-- -   __DOWNLOADING\/VALIDATING\/BUILDING\/ACTIVATING__ -- GameLift is
--     setting up the new fleet location, creating new instances with the
--     game build or Realtime script and starting server processes.
--
-- -   __ACTIVE__ -- Hosts can now accept game sessions.
--
-- -   __ERROR__ -- An error occurred when downloading, validating,
--     building, or activating the fleet location.
--
-- -   __DELETING__ -- Hosts are responding to a delete fleet location
--     request.
--
-- -   __TERMINATED__ -- The fleet location no longer exists.
--
-- -   __NOT_FOUND__ -- The fleet location was not found. This could be
--     because the custom location was removed or not created.
--
-- /See:/ 'newLocationState' smart constructor.
data LocationState = LocationState'
  { -- | The fleet location, expressed as an Amazon Web Services Region code such
    -- as @us-west-2@.
    LocationState -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | The life-cycle status of a fleet location.
    LocationState -> Maybe FleetStatus
status :: Prelude.Maybe FleetStatus
  }
  deriving (LocationState -> LocationState -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LocationState -> LocationState -> Bool
$c/= :: LocationState -> LocationState -> Bool
== :: LocationState -> LocationState -> Bool
$c== :: LocationState -> LocationState -> Bool
Prelude.Eq, ReadPrec [LocationState]
ReadPrec LocationState
Int -> ReadS LocationState
ReadS [LocationState]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LocationState]
$creadListPrec :: ReadPrec [LocationState]
readPrec :: ReadPrec LocationState
$creadPrec :: ReadPrec LocationState
readList :: ReadS [LocationState]
$creadList :: ReadS [LocationState]
readsPrec :: Int -> ReadS LocationState
$creadsPrec :: Int -> ReadS LocationState
Prelude.Read, Int -> LocationState -> ShowS
[LocationState] -> ShowS
LocationState -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LocationState] -> ShowS
$cshowList :: [LocationState] -> ShowS
show :: LocationState -> String
$cshow :: LocationState -> String
showsPrec :: Int -> LocationState -> ShowS
$cshowsPrec :: Int -> LocationState -> ShowS
Prelude.Show, forall x. Rep LocationState x -> LocationState
forall x. LocationState -> Rep LocationState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LocationState x -> LocationState
$cfrom :: forall x. LocationState -> Rep LocationState x
Prelude.Generic)

-- |
-- Create a value of 'LocationState' 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:
--
-- 'location', 'locationState_location' - The fleet location, expressed as an Amazon Web Services Region code such
-- as @us-west-2@.
--
-- 'status', 'locationState_status' - The life-cycle status of a fleet location.
newLocationState ::
  LocationState
newLocationState :: LocationState
newLocationState =
  LocationState'
    { $sel:location:LocationState' :: Maybe Text
location = forall a. Maybe a
Prelude.Nothing,
      $sel:status:LocationState' :: Maybe FleetStatus
status = forall a. Maybe a
Prelude.Nothing
    }

-- | The fleet location, expressed as an Amazon Web Services Region code such
-- as @us-west-2@.
locationState_location :: Lens.Lens' LocationState (Prelude.Maybe Prelude.Text)
locationState_location :: Lens' LocationState (Maybe Text)
locationState_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocationState' {Maybe Text
location :: Maybe Text
$sel:location:LocationState' :: LocationState -> Maybe Text
location} -> Maybe Text
location) (\s :: LocationState
s@LocationState' {} Maybe Text
a -> LocationState
s {$sel:location:LocationState' :: Maybe Text
location = Maybe Text
a} :: LocationState)

-- | The life-cycle status of a fleet location.
locationState_status :: Lens.Lens' LocationState (Prelude.Maybe FleetStatus)
locationState_status :: Lens' LocationState (Maybe FleetStatus)
locationState_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LocationState' {Maybe FleetStatus
status :: Maybe FleetStatus
$sel:status:LocationState' :: LocationState -> Maybe FleetStatus
status} -> Maybe FleetStatus
status) (\s :: LocationState
s@LocationState' {} Maybe FleetStatus
a -> LocationState
s {$sel:status:LocationState' :: Maybe FleetStatus
status = Maybe FleetStatus
a} :: LocationState)

instance Data.FromJSON LocationState where
  parseJSON :: Value -> Parser LocationState
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LocationState"
      ( \Object
x ->
          Maybe Text -> Maybe FleetStatus -> LocationState
LocationState'
            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
"Location")
            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
"Status")
      )

instance Prelude.Hashable LocationState where
  hashWithSalt :: Int -> LocationState -> Int
hashWithSalt Int
_salt LocationState' {Maybe Text
Maybe FleetStatus
status :: Maybe FleetStatus
location :: Maybe Text
$sel:status:LocationState' :: LocationState -> Maybe FleetStatus
$sel:location:LocationState' :: LocationState -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FleetStatus
status

instance Prelude.NFData LocationState where
  rnf :: LocationState -> ()
rnf LocationState' {Maybe Text
Maybe FleetStatus
status :: Maybe FleetStatus
location :: Maybe Text
$sel:status:LocationState' :: LocationState -> Maybe FleetStatus
$sel:location:LocationState' :: LocationState -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FleetStatus
status