{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.DescribeRuntimeConfiguration
-- 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)
--
-- Retrieves a fleet\'s runtime configuration settings. The runtime
-- configuration tells GameLift which server processes to run (and how) on
-- each instance in the fleet.
--
-- To get the runtime configuration that is currently in forces for a
-- fleet, provide the fleet ID.
--
-- If successful, a RuntimeConfiguration object is returned for the
-- requested fleet. If the requested fleet has been deleted, the result set
-- is empty.
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-intro.html Setting up GameLift fleets>
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-multiprocess.html Running multiple processes on a fleet>
--
-- __Related actions__
--
-- ListFleets | DescribeEC2InstanceLimits | DescribeFleetAttributes |
-- DescribeFleetCapacity | DescribeFleetEvents |
-- DescribeFleetLocationAttributes | DescribeFleetPortSettings |
-- DescribeFleetUtilization | DescribeRuntimeConfiguration |
-- DescribeScalingPolicies |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
module Amazonka.GameLift.DescribeRuntimeConfiguration
  ( -- * Creating a Request
    DescribeRuntimeConfiguration (..),
    newDescribeRuntimeConfiguration,

    -- * Request Lenses
    describeRuntimeConfiguration_fleetId,

    -- * Destructuring the Response
    DescribeRuntimeConfigurationResponse (..),
    newDescribeRuntimeConfigurationResponse,

    -- * Response Lenses
    describeRuntimeConfigurationResponse_runtimeConfiguration,
    describeRuntimeConfigurationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input for a request operation.
--
-- /See:/ 'newDescribeRuntimeConfiguration' smart constructor.
data DescribeRuntimeConfiguration = DescribeRuntimeConfiguration'
  { -- | A unique identifier for the fleet to get the runtime configuration for.
    -- You can use either the fleet ID or ARN value.
    DescribeRuntimeConfiguration -> Text
fleetId :: Prelude.Text
  }
  deriving (DescribeRuntimeConfiguration
-> DescribeRuntimeConfiguration -> Bool
(DescribeRuntimeConfiguration
 -> DescribeRuntimeConfiguration -> Bool)
-> (DescribeRuntimeConfiguration
    -> DescribeRuntimeConfiguration -> Bool)
-> Eq DescribeRuntimeConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRuntimeConfiguration
-> DescribeRuntimeConfiguration -> Bool
$c/= :: DescribeRuntimeConfiguration
-> DescribeRuntimeConfiguration -> Bool
== :: DescribeRuntimeConfiguration
-> DescribeRuntimeConfiguration -> Bool
$c== :: DescribeRuntimeConfiguration
-> DescribeRuntimeConfiguration -> Bool
Prelude.Eq, ReadPrec [DescribeRuntimeConfiguration]
ReadPrec DescribeRuntimeConfiguration
Int -> ReadS DescribeRuntimeConfiguration
ReadS [DescribeRuntimeConfiguration]
(Int -> ReadS DescribeRuntimeConfiguration)
-> ReadS [DescribeRuntimeConfiguration]
-> ReadPrec DescribeRuntimeConfiguration
-> ReadPrec [DescribeRuntimeConfiguration]
-> Read DescribeRuntimeConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRuntimeConfiguration]
$creadListPrec :: ReadPrec [DescribeRuntimeConfiguration]
readPrec :: ReadPrec DescribeRuntimeConfiguration
$creadPrec :: ReadPrec DescribeRuntimeConfiguration
readList :: ReadS [DescribeRuntimeConfiguration]
$creadList :: ReadS [DescribeRuntimeConfiguration]
readsPrec :: Int -> ReadS DescribeRuntimeConfiguration
$creadsPrec :: Int -> ReadS DescribeRuntimeConfiguration
Prelude.Read, Int -> DescribeRuntimeConfiguration -> ShowS
[DescribeRuntimeConfiguration] -> ShowS
DescribeRuntimeConfiguration -> String
(Int -> DescribeRuntimeConfiguration -> ShowS)
-> (DescribeRuntimeConfiguration -> String)
-> ([DescribeRuntimeConfiguration] -> ShowS)
-> Show DescribeRuntimeConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRuntimeConfiguration] -> ShowS
$cshowList :: [DescribeRuntimeConfiguration] -> ShowS
show :: DescribeRuntimeConfiguration -> String
$cshow :: DescribeRuntimeConfiguration -> String
showsPrec :: Int -> DescribeRuntimeConfiguration -> ShowS
$cshowsPrec :: Int -> DescribeRuntimeConfiguration -> ShowS
Prelude.Show, (forall x.
 DescribeRuntimeConfiguration -> Rep DescribeRuntimeConfiguration x)
-> (forall x.
    Rep DescribeRuntimeConfiguration x -> DescribeRuntimeConfiguration)
-> Generic DescribeRuntimeConfiguration
forall x.
Rep DescribeRuntimeConfiguration x -> DescribeRuntimeConfiguration
forall x.
DescribeRuntimeConfiguration -> Rep DescribeRuntimeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeRuntimeConfiguration x -> DescribeRuntimeConfiguration
$cfrom :: forall x.
DescribeRuntimeConfiguration -> Rep DescribeRuntimeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRuntimeConfiguration' 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:
--
-- 'fleetId', 'describeRuntimeConfiguration_fleetId' - A unique identifier for the fleet to get the runtime configuration for.
-- You can use either the fleet ID or ARN value.
newDescribeRuntimeConfiguration ::
  -- | 'fleetId'
  Prelude.Text ->
  DescribeRuntimeConfiguration
newDescribeRuntimeConfiguration :: Text -> DescribeRuntimeConfiguration
newDescribeRuntimeConfiguration Text
pFleetId_ =
  DescribeRuntimeConfiguration' :: Text -> DescribeRuntimeConfiguration
DescribeRuntimeConfiguration' {$sel:fleetId:DescribeRuntimeConfiguration' :: Text
fleetId = Text
pFleetId_}

-- | A unique identifier for the fleet to get the runtime configuration for.
-- You can use either the fleet ID or ARN value.
describeRuntimeConfiguration_fleetId :: Lens.Lens' DescribeRuntimeConfiguration Prelude.Text
describeRuntimeConfiguration_fleetId :: (Text -> f Text)
-> DescribeRuntimeConfiguration -> f DescribeRuntimeConfiguration
describeRuntimeConfiguration_fleetId = (DescribeRuntimeConfiguration -> Text)
-> (DescribeRuntimeConfiguration
    -> Text -> DescribeRuntimeConfiguration)
-> Lens
     DescribeRuntimeConfiguration DescribeRuntimeConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRuntimeConfiguration' {Text
fleetId :: Text
$sel:fleetId:DescribeRuntimeConfiguration' :: DescribeRuntimeConfiguration -> Text
fleetId} -> Text
fleetId) (\s :: DescribeRuntimeConfiguration
s@DescribeRuntimeConfiguration' {} Text
a -> DescribeRuntimeConfiguration
s {$sel:fleetId:DescribeRuntimeConfiguration' :: Text
fleetId = Text
a} :: DescribeRuntimeConfiguration)

instance Core.AWSRequest DescribeRuntimeConfiguration where
  type
    AWSResponse DescribeRuntimeConfiguration =
      DescribeRuntimeConfigurationResponse
  request :: DescribeRuntimeConfiguration
-> Request DescribeRuntimeConfiguration
request = Service
-> DescribeRuntimeConfiguration
-> Request DescribeRuntimeConfiguration
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeRuntimeConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRuntimeConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeRuntimeConfiguration))
-> Logger
-> Service
-> Proxy DescribeRuntimeConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRuntimeConfiguration)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe RuntimeConfiguration
-> Int -> DescribeRuntimeConfigurationResponse
DescribeRuntimeConfigurationResponse'
            (Maybe RuntimeConfiguration
 -> Int -> DescribeRuntimeConfigurationResponse)
-> Either String (Maybe RuntimeConfiguration)
-> Either String (Int -> DescribeRuntimeConfigurationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RuntimeConfiguration)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RuntimeConfiguration")
            Either String (Int -> DescribeRuntimeConfigurationResponse)
-> Either String Int
-> Either String DescribeRuntimeConfigurationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    DescribeRuntimeConfiguration

instance Prelude.NFData DescribeRuntimeConfiguration

instance Core.ToHeaders DescribeRuntimeConfiguration where
  toHeaders :: DescribeRuntimeConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeRuntimeConfiguration -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"GameLift.DescribeRuntimeConfiguration" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeRuntimeConfiguration where
  toJSON :: DescribeRuntimeConfiguration -> Value
toJSON DescribeRuntimeConfiguration' {Text
fleetId :: Text
$sel:fleetId:DescribeRuntimeConfiguration' :: DescribeRuntimeConfiguration -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FleetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fleetId)]
      )

instance Core.ToPath DescribeRuntimeConfiguration where
  toPath :: DescribeRuntimeConfiguration -> ByteString
toPath = ByteString -> DescribeRuntimeConfiguration -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DescribeRuntimeConfiguration where
  toQuery :: DescribeRuntimeConfiguration -> QueryString
toQuery = QueryString -> DescribeRuntimeConfiguration -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | Represents the returned data in response to a request operation.
--
-- /See:/ 'newDescribeRuntimeConfigurationResponse' smart constructor.
data DescribeRuntimeConfigurationResponse = DescribeRuntimeConfigurationResponse'
  { -- | Instructions that describe how server processes should be launched and
    -- maintained on each instance in the fleet.
    DescribeRuntimeConfigurationResponse -> Maybe RuntimeConfiguration
runtimeConfiguration :: Prelude.Maybe RuntimeConfiguration,
    -- | The response's http status code.
    DescribeRuntimeConfigurationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeRuntimeConfigurationResponse
-> DescribeRuntimeConfigurationResponse -> Bool
(DescribeRuntimeConfigurationResponse
 -> DescribeRuntimeConfigurationResponse -> Bool)
-> (DescribeRuntimeConfigurationResponse
    -> DescribeRuntimeConfigurationResponse -> Bool)
-> Eq DescribeRuntimeConfigurationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRuntimeConfigurationResponse
-> DescribeRuntimeConfigurationResponse -> Bool
$c/= :: DescribeRuntimeConfigurationResponse
-> DescribeRuntimeConfigurationResponse -> Bool
== :: DescribeRuntimeConfigurationResponse
-> DescribeRuntimeConfigurationResponse -> Bool
$c== :: DescribeRuntimeConfigurationResponse
-> DescribeRuntimeConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [DescribeRuntimeConfigurationResponse]
ReadPrec DescribeRuntimeConfigurationResponse
Int -> ReadS DescribeRuntimeConfigurationResponse
ReadS [DescribeRuntimeConfigurationResponse]
(Int -> ReadS DescribeRuntimeConfigurationResponse)
-> ReadS [DescribeRuntimeConfigurationResponse]
-> ReadPrec DescribeRuntimeConfigurationResponse
-> ReadPrec [DescribeRuntimeConfigurationResponse]
-> Read DescribeRuntimeConfigurationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRuntimeConfigurationResponse]
$creadListPrec :: ReadPrec [DescribeRuntimeConfigurationResponse]
readPrec :: ReadPrec DescribeRuntimeConfigurationResponse
$creadPrec :: ReadPrec DescribeRuntimeConfigurationResponse
readList :: ReadS [DescribeRuntimeConfigurationResponse]
$creadList :: ReadS [DescribeRuntimeConfigurationResponse]
readsPrec :: Int -> ReadS DescribeRuntimeConfigurationResponse
$creadsPrec :: Int -> ReadS DescribeRuntimeConfigurationResponse
Prelude.Read, Int -> DescribeRuntimeConfigurationResponse -> ShowS
[DescribeRuntimeConfigurationResponse] -> ShowS
DescribeRuntimeConfigurationResponse -> String
(Int -> DescribeRuntimeConfigurationResponse -> ShowS)
-> (DescribeRuntimeConfigurationResponse -> String)
-> ([DescribeRuntimeConfigurationResponse] -> ShowS)
-> Show DescribeRuntimeConfigurationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRuntimeConfigurationResponse] -> ShowS
$cshowList :: [DescribeRuntimeConfigurationResponse] -> ShowS
show :: DescribeRuntimeConfigurationResponse -> String
$cshow :: DescribeRuntimeConfigurationResponse -> String
showsPrec :: Int -> DescribeRuntimeConfigurationResponse -> ShowS
$cshowsPrec :: Int -> DescribeRuntimeConfigurationResponse -> ShowS
Prelude.Show, (forall x.
 DescribeRuntimeConfigurationResponse
 -> Rep DescribeRuntimeConfigurationResponse x)
-> (forall x.
    Rep DescribeRuntimeConfigurationResponse x
    -> DescribeRuntimeConfigurationResponse)
-> Generic DescribeRuntimeConfigurationResponse
forall x.
Rep DescribeRuntimeConfigurationResponse x
-> DescribeRuntimeConfigurationResponse
forall x.
DescribeRuntimeConfigurationResponse
-> Rep DescribeRuntimeConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeRuntimeConfigurationResponse x
-> DescribeRuntimeConfigurationResponse
$cfrom :: forall x.
DescribeRuntimeConfigurationResponse
-> Rep DescribeRuntimeConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRuntimeConfigurationResponse' 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:
--
-- 'runtimeConfiguration', 'describeRuntimeConfigurationResponse_runtimeConfiguration' - Instructions that describe how server processes should be launched and
-- maintained on each instance in the fleet.
--
-- 'httpStatus', 'describeRuntimeConfigurationResponse_httpStatus' - The response's http status code.
newDescribeRuntimeConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeRuntimeConfigurationResponse
newDescribeRuntimeConfigurationResponse :: Int -> DescribeRuntimeConfigurationResponse
newDescribeRuntimeConfigurationResponse Int
pHttpStatus_ =
  DescribeRuntimeConfigurationResponse' :: Maybe RuntimeConfiguration
-> Int -> DescribeRuntimeConfigurationResponse
DescribeRuntimeConfigurationResponse'
    { $sel:runtimeConfiguration:DescribeRuntimeConfigurationResponse' :: Maybe RuntimeConfiguration
runtimeConfiguration =
        Maybe RuntimeConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeRuntimeConfigurationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Instructions that describe how server processes should be launched and
-- maintained on each instance in the fleet.
describeRuntimeConfigurationResponse_runtimeConfiguration :: Lens.Lens' DescribeRuntimeConfigurationResponse (Prelude.Maybe RuntimeConfiguration)
describeRuntimeConfigurationResponse_runtimeConfiguration :: (Maybe RuntimeConfiguration -> f (Maybe RuntimeConfiguration))
-> DescribeRuntimeConfigurationResponse
-> f DescribeRuntimeConfigurationResponse
describeRuntimeConfigurationResponse_runtimeConfiguration = (DescribeRuntimeConfigurationResponse
 -> Maybe RuntimeConfiguration)
-> (DescribeRuntimeConfigurationResponse
    -> Maybe RuntimeConfiguration
    -> DescribeRuntimeConfigurationResponse)
-> Lens
     DescribeRuntimeConfigurationResponse
     DescribeRuntimeConfigurationResponse
     (Maybe RuntimeConfiguration)
     (Maybe RuntimeConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRuntimeConfigurationResponse' {Maybe RuntimeConfiguration
runtimeConfiguration :: Maybe RuntimeConfiguration
$sel:runtimeConfiguration:DescribeRuntimeConfigurationResponse' :: DescribeRuntimeConfigurationResponse -> Maybe RuntimeConfiguration
runtimeConfiguration} -> Maybe RuntimeConfiguration
runtimeConfiguration) (\s :: DescribeRuntimeConfigurationResponse
s@DescribeRuntimeConfigurationResponse' {} Maybe RuntimeConfiguration
a -> DescribeRuntimeConfigurationResponse
s {$sel:runtimeConfiguration:DescribeRuntimeConfigurationResponse' :: Maybe RuntimeConfiguration
runtimeConfiguration = Maybe RuntimeConfiguration
a} :: DescribeRuntimeConfigurationResponse)

-- | The response's http status code.
describeRuntimeConfigurationResponse_httpStatus :: Lens.Lens' DescribeRuntimeConfigurationResponse Prelude.Int
describeRuntimeConfigurationResponse_httpStatus :: (Int -> f Int)
-> DescribeRuntimeConfigurationResponse
-> f DescribeRuntimeConfigurationResponse
describeRuntimeConfigurationResponse_httpStatus = (DescribeRuntimeConfigurationResponse -> Int)
-> (DescribeRuntimeConfigurationResponse
    -> Int -> DescribeRuntimeConfigurationResponse)
-> Lens
     DescribeRuntimeConfigurationResponse
     DescribeRuntimeConfigurationResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRuntimeConfigurationResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeRuntimeConfigurationResponse' :: DescribeRuntimeConfigurationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeRuntimeConfigurationResponse
s@DescribeRuntimeConfigurationResponse' {} Int
a -> DescribeRuntimeConfigurationResponse
s {$sel:httpStatus:DescribeRuntimeConfigurationResponse' :: Int
httpStatus = Int
a} :: DescribeRuntimeConfigurationResponse)

instance
  Prelude.NFData
    DescribeRuntimeConfigurationResponse