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

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types.FleetStatus
import qualified Amazonka.Lens as Lens
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.
--
-- __Related actions__
--
-- CreateFleet | CreateFleetLocations | DeleteFleetLocations
--
-- /See:/ 'newLocationState' smart constructor.
data LocationState = LocationState'
  { -- | The life-cycle status of a fleet location.
    LocationState -> Maybe FleetStatus
status :: Prelude.Maybe FleetStatus,
    -- | The fleet location, expressed as an AWS Region code such as @us-west-2@.
    LocationState -> Maybe Text
location :: Prelude.Maybe Prelude.Text
  }
  deriving (LocationState -> LocationState -> Bool
(LocationState -> LocationState -> Bool)
-> (LocationState -> LocationState -> Bool) -> Eq LocationState
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]
(Int -> ReadS LocationState)
-> ReadS [LocationState]
-> ReadPrec LocationState
-> ReadPrec [LocationState]
-> Read 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
(Int -> LocationState -> ShowS)
-> (LocationState -> String)
-> ([LocationState] -> ShowS)
-> Show LocationState
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. LocationState -> Rep LocationState x)
-> (forall x. Rep LocationState x -> LocationState)
-> Generic LocationState
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:
--
-- 'status', 'locationState_status' - The life-cycle status of a fleet location.
--
-- 'location', 'locationState_location' - The fleet location, expressed as an AWS Region code such as @us-west-2@.
newLocationState ::
  LocationState
newLocationState :: LocationState
newLocationState =
  LocationState' :: Maybe FleetStatus -> Maybe Text -> LocationState
LocationState'
    { $sel:status:LocationState' :: Maybe FleetStatus
status = Maybe FleetStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:location:LocationState' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The life-cycle status of a fleet location.
locationState_status :: Lens.Lens' LocationState (Prelude.Maybe FleetStatus)
locationState_status :: (Maybe FleetStatus -> f (Maybe FleetStatus))
-> LocationState -> f LocationState
locationState_status = (LocationState -> Maybe FleetStatus)
-> (LocationState -> Maybe FleetStatus -> LocationState)
-> Lens
     LocationState LocationState (Maybe FleetStatus) (Maybe FleetStatus)
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)

-- | The fleet location, expressed as an AWS Region code such as @us-west-2@.
locationState_location :: Lens.Lens' LocationState (Prelude.Maybe Prelude.Text)
locationState_location :: (Maybe Text -> f (Maybe Text)) -> LocationState -> f LocationState
locationState_location = (LocationState -> Maybe Text)
-> (LocationState -> Maybe Text -> LocationState)
-> Lens LocationState LocationState (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON LocationState where
  parseJSON :: Value -> Parser LocationState
parseJSON =
    String
-> (Object -> Parser LocationState)
-> Value
-> Parser LocationState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LocationState"
      ( \Object
x ->
          Maybe FleetStatus -> Maybe Text -> LocationState
LocationState'
            (Maybe FleetStatus -> Maybe Text -> LocationState)
-> Parser (Maybe FleetStatus)
-> Parser (Maybe Text -> LocationState)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FleetStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser (Maybe Text -> LocationState)
-> Parser (Maybe Text) -> Parser LocationState
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
"Location")
      )

instance Prelude.Hashable LocationState

instance Prelude.NFData LocationState