{-# 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.UpdateRuntimeConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the current runtime configuration for the specified fleet, which
-- tells GameLift how to launch server processes on all instances in the
-- fleet. You can update a fleet\'s runtime configuration at any time after
-- the fleet is created; it does not need to be in @ACTIVE@ status.
--
-- To update runtime configuration, specify the fleet ID and provide a
-- @RuntimeConfiguration@ with an updated set of server process
-- configurations.
--
-- If successful, the fleet\'s runtime configuration settings are updated.
-- Each instance in the fleet regularly checks for and retrieves updated
-- runtime configurations. Instances immediately begin complying with the
-- new configuration by launching new server processes or not replacing
-- existing processes when they shut down. Updating a fleet\'s runtime
-- configuration never affects existing server processes.
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-intro.html Setting up GameLift fleets>
module Amazonka.GameLift.UpdateRuntimeConfiguration
  ( -- * Creating a Request
    UpdateRuntimeConfiguration (..),
    newUpdateRuntimeConfiguration,

    -- * Request Lenses
    updateRuntimeConfiguration_fleetId,
    updateRuntimeConfiguration_runtimeConfiguration,

    -- * Destructuring the Response
    UpdateRuntimeConfigurationResponse (..),
    newUpdateRuntimeConfigurationResponse,

    -- * Response Lenses
    updateRuntimeConfigurationResponse_runtimeConfiguration,
    updateRuntimeConfigurationResponse_httpStatus,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateRuntimeConfiguration' smart constructor.
data UpdateRuntimeConfiguration = UpdateRuntimeConfiguration'
  { -- | A unique identifier for the fleet to update runtime configuration for.
    -- You can use either the fleet ID or ARN value.
    UpdateRuntimeConfiguration -> Text
fleetId :: Prelude.Text,
    -- | Instructions for alaunching server processes on each instance in the
    -- fleet. Server processes run either a custom game build executable or a
    -- Realtime Servers script. The runtime configuration lists the types of
    -- server processes to run on an instance, how to launch them, and the
    -- number of processes to run concurrently.
    UpdateRuntimeConfiguration -> RuntimeConfiguration
runtimeConfiguration :: RuntimeConfiguration
  }
  deriving (UpdateRuntimeConfiguration -> UpdateRuntimeConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRuntimeConfiguration -> UpdateRuntimeConfiguration -> Bool
$c/= :: UpdateRuntimeConfiguration -> UpdateRuntimeConfiguration -> Bool
== :: UpdateRuntimeConfiguration -> UpdateRuntimeConfiguration -> Bool
$c== :: UpdateRuntimeConfiguration -> UpdateRuntimeConfiguration -> Bool
Prelude.Eq, ReadPrec [UpdateRuntimeConfiguration]
ReadPrec UpdateRuntimeConfiguration
Int -> ReadS UpdateRuntimeConfiguration
ReadS [UpdateRuntimeConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRuntimeConfiguration]
$creadListPrec :: ReadPrec [UpdateRuntimeConfiguration]
readPrec :: ReadPrec UpdateRuntimeConfiguration
$creadPrec :: ReadPrec UpdateRuntimeConfiguration
readList :: ReadS [UpdateRuntimeConfiguration]
$creadList :: ReadS [UpdateRuntimeConfiguration]
readsPrec :: Int -> ReadS UpdateRuntimeConfiguration
$creadsPrec :: Int -> ReadS UpdateRuntimeConfiguration
Prelude.Read, Int -> UpdateRuntimeConfiguration -> ShowS
[UpdateRuntimeConfiguration] -> ShowS
UpdateRuntimeConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRuntimeConfiguration] -> ShowS
$cshowList :: [UpdateRuntimeConfiguration] -> ShowS
show :: UpdateRuntimeConfiguration -> String
$cshow :: UpdateRuntimeConfiguration -> String
showsPrec :: Int -> UpdateRuntimeConfiguration -> ShowS
$cshowsPrec :: Int -> UpdateRuntimeConfiguration -> ShowS
Prelude.Show, forall x.
Rep UpdateRuntimeConfiguration x -> UpdateRuntimeConfiguration
forall x.
UpdateRuntimeConfiguration -> Rep UpdateRuntimeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateRuntimeConfiguration x -> UpdateRuntimeConfiguration
$cfrom :: forall x.
UpdateRuntimeConfiguration -> Rep UpdateRuntimeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRuntimeConfiguration' 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', 'updateRuntimeConfiguration_fleetId' - A unique identifier for the fleet to update runtime configuration for.
-- You can use either the fleet ID or ARN value.
--
-- 'runtimeConfiguration', 'updateRuntimeConfiguration_runtimeConfiguration' - Instructions for alaunching server processes on each instance in the
-- fleet. Server processes run either a custom game build executable or a
-- Realtime Servers script. The runtime configuration lists the types of
-- server processes to run on an instance, how to launch them, and the
-- number of processes to run concurrently.
newUpdateRuntimeConfiguration ::
  -- | 'fleetId'
  Prelude.Text ->
  -- | 'runtimeConfiguration'
  RuntimeConfiguration ->
  UpdateRuntimeConfiguration
newUpdateRuntimeConfiguration :: Text -> RuntimeConfiguration -> UpdateRuntimeConfiguration
newUpdateRuntimeConfiguration
  Text
pFleetId_
  RuntimeConfiguration
pRuntimeConfiguration_ =
    UpdateRuntimeConfiguration'
      { $sel:fleetId:UpdateRuntimeConfiguration' :: Text
fleetId = Text
pFleetId_,
        $sel:runtimeConfiguration:UpdateRuntimeConfiguration' :: RuntimeConfiguration
runtimeConfiguration = RuntimeConfiguration
pRuntimeConfiguration_
      }

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

-- | Instructions for alaunching server processes on each instance in the
-- fleet. Server processes run either a custom game build executable or a
-- Realtime Servers script. The runtime configuration lists the types of
-- server processes to run on an instance, how to launch them, and the
-- number of processes to run concurrently.
updateRuntimeConfiguration_runtimeConfiguration :: Lens.Lens' UpdateRuntimeConfiguration RuntimeConfiguration
updateRuntimeConfiguration_runtimeConfiguration :: Lens' UpdateRuntimeConfiguration RuntimeConfiguration
updateRuntimeConfiguration_runtimeConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuntimeConfiguration' {RuntimeConfiguration
runtimeConfiguration :: RuntimeConfiguration
$sel:runtimeConfiguration:UpdateRuntimeConfiguration' :: UpdateRuntimeConfiguration -> RuntimeConfiguration
runtimeConfiguration} -> RuntimeConfiguration
runtimeConfiguration) (\s :: UpdateRuntimeConfiguration
s@UpdateRuntimeConfiguration' {} RuntimeConfiguration
a -> UpdateRuntimeConfiguration
s {$sel:runtimeConfiguration:UpdateRuntimeConfiguration' :: RuntimeConfiguration
runtimeConfiguration = RuntimeConfiguration
a} :: UpdateRuntimeConfiguration)

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

instance Prelude.Hashable UpdateRuntimeConfiguration where
  hashWithSalt :: Int -> UpdateRuntimeConfiguration -> Int
hashWithSalt Int
_salt UpdateRuntimeConfiguration' {Text
RuntimeConfiguration
runtimeConfiguration :: RuntimeConfiguration
fleetId :: Text
$sel:runtimeConfiguration:UpdateRuntimeConfiguration' :: UpdateRuntimeConfiguration -> RuntimeConfiguration
$sel:fleetId:UpdateRuntimeConfiguration' :: UpdateRuntimeConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fleetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RuntimeConfiguration
runtimeConfiguration

instance Prelude.NFData UpdateRuntimeConfiguration where
  rnf :: UpdateRuntimeConfiguration -> ()
rnf UpdateRuntimeConfiguration' {Text
RuntimeConfiguration
runtimeConfiguration :: RuntimeConfiguration
fleetId :: Text
$sel:runtimeConfiguration:UpdateRuntimeConfiguration' :: UpdateRuntimeConfiguration -> RuntimeConfiguration
$sel:fleetId:UpdateRuntimeConfiguration' :: UpdateRuntimeConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
fleetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RuntimeConfiguration
runtimeConfiguration

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

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

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

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

-- | /See:/ 'newUpdateRuntimeConfigurationResponse' smart constructor.
data UpdateRuntimeConfigurationResponse = UpdateRuntimeConfigurationResponse'
  { -- | The runtime configuration currently in use by all instances in the
    -- fleet. If the update was successful, all property changes are shown.
    UpdateRuntimeConfigurationResponse -> Maybe RuntimeConfiguration
runtimeConfiguration :: Prelude.Maybe RuntimeConfiguration,
    -- | The response's http status code.
    UpdateRuntimeConfigurationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateRuntimeConfigurationResponse
-> UpdateRuntimeConfigurationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRuntimeConfigurationResponse
-> UpdateRuntimeConfigurationResponse -> Bool
$c/= :: UpdateRuntimeConfigurationResponse
-> UpdateRuntimeConfigurationResponse -> Bool
== :: UpdateRuntimeConfigurationResponse
-> UpdateRuntimeConfigurationResponse -> Bool
$c== :: UpdateRuntimeConfigurationResponse
-> UpdateRuntimeConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [UpdateRuntimeConfigurationResponse]
ReadPrec UpdateRuntimeConfigurationResponse
Int -> ReadS UpdateRuntimeConfigurationResponse
ReadS [UpdateRuntimeConfigurationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRuntimeConfigurationResponse]
$creadListPrec :: ReadPrec [UpdateRuntimeConfigurationResponse]
readPrec :: ReadPrec UpdateRuntimeConfigurationResponse
$creadPrec :: ReadPrec UpdateRuntimeConfigurationResponse
readList :: ReadS [UpdateRuntimeConfigurationResponse]
$creadList :: ReadS [UpdateRuntimeConfigurationResponse]
readsPrec :: Int -> ReadS UpdateRuntimeConfigurationResponse
$creadsPrec :: Int -> ReadS UpdateRuntimeConfigurationResponse
Prelude.Read, Int -> UpdateRuntimeConfigurationResponse -> ShowS
[UpdateRuntimeConfigurationResponse] -> ShowS
UpdateRuntimeConfigurationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRuntimeConfigurationResponse] -> ShowS
$cshowList :: [UpdateRuntimeConfigurationResponse] -> ShowS
show :: UpdateRuntimeConfigurationResponse -> String
$cshow :: UpdateRuntimeConfigurationResponse -> String
showsPrec :: Int -> UpdateRuntimeConfigurationResponse -> ShowS
$cshowsPrec :: Int -> UpdateRuntimeConfigurationResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateRuntimeConfigurationResponse x
-> UpdateRuntimeConfigurationResponse
forall x.
UpdateRuntimeConfigurationResponse
-> Rep UpdateRuntimeConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateRuntimeConfigurationResponse x
-> UpdateRuntimeConfigurationResponse
$cfrom :: forall x.
UpdateRuntimeConfigurationResponse
-> Rep UpdateRuntimeConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRuntimeConfigurationResponse' 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', 'updateRuntimeConfigurationResponse_runtimeConfiguration' - The runtime configuration currently in use by all instances in the
-- fleet. If the update was successful, all property changes are shown.
--
-- 'httpStatus', 'updateRuntimeConfigurationResponse_httpStatus' - The response's http status code.
newUpdateRuntimeConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateRuntimeConfigurationResponse
newUpdateRuntimeConfigurationResponse :: Int -> UpdateRuntimeConfigurationResponse
newUpdateRuntimeConfigurationResponse Int
pHttpStatus_ =
  UpdateRuntimeConfigurationResponse'
    { $sel:runtimeConfiguration:UpdateRuntimeConfigurationResponse' :: Maybe RuntimeConfiguration
runtimeConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateRuntimeConfigurationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The runtime configuration currently in use by all instances in the
-- fleet. If the update was successful, all property changes are shown.
updateRuntimeConfigurationResponse_runtimeConfiguration :: Lens.Lens' UpdateRuntimeConfigurationResponse (Prelude.Maybe RuntimeConfiguration)
updateRuntimeConfigurationResponse_runtimeConfiguration :: Lens'
  UpdateRuntimeConfigurationResponse (Maybe RuntimeConfiguration)
updateRuntimeConfigurationResponse_runtimeConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRuntimeConfigurationResponse' {Maybe RuntimeConfiguration
runtimeConfiguration :: Maybe RuntimeConfiguration
$sel:runtimeConfiguration:UpdateRuntimeConfigurationResponse' :: UpdateRuntimeConfigurationResponse -> Maybe RuntimeConfiguration
runtimeConfiguration} -> Maybe RuntimeConfiguration
runtimeConfiguration) (\s :: UpdateRuntimeConfigurationResponse
s@UpdateRuntimeConfigurationResponse' {} Maybe RuntimeConfiguration
a -> UpdateRuntimeConfigurationResponse
s {$sel:runtimeConfiguration:UpdateRuntimeConfigurationResponse' :: Maybe RuntimeConfiguration
runtimeConfiguration = Maybe RuntimeConfiguration
a} :: UpdateRuntimeConfigurationResponse)

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

instance
  Prelude.NFData
    UpdateRuntimeConfigurationResponse
  where
  rnf :: UpdateRuntimeConfigurationResponse -> ()
rnf UpdateRuntimeConfigurationResponse' {Int
Maybe RuntimeConfiguration
httpStatus :: Int
runtimeConfiguration :: Maybe RuntimeConfiguration
$sel:httpStatus:UpdateRuntimeConfigurationResponse' :: UpdateRuntimeConfigurationResponse -> Int
$sel:runtimeConfiguration:UpdateRuntimeConfigurationResponse' :: UpdateRuntimeConfigurationResponse -> Maybe RuntimeConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RuntimeConfiguration
runtimeConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus