{-# 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.GamesParks.UpdateGameConfiguration
-- 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 one or more sections of the game configuration.
module Amazonka.GamesParks.UpdateGameConfiguration
  ( -- * Creating a Request
    UpdateGameConfiguration (..),
    newUpdateGameConfiguration,

    -- * Request Lenses
    updateGameConfiguration_gameName,
    updateGameConfiguration_modifications,

    -- * Destructuring the Response
    UpdateGameConfigurationResponse (..),
    newUpdateGameConfigurationResponse,

    -- * Response Lenses
    updateGameConfigurationResponse_gameConfiguration,
    updateGameConfigurationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GamesParks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateGameConfiguration' smart constructor.
data UpdateGameConfiguration = UpdateGameConfiguration'
  { -- | The name of the game.
    UpdateGameConfiguration -> Text
gameName :: Prelude.Text,
    -- | The list of modifications to make.
    UpdateGameConfiguration -> NonEmpty SectionModification
modifications :: Prelude.NonEmpty SectionModification
  }
  deriving (UpdateGameConfiguration -> UpdateGameConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGameConfiguration -> UpdateGameConfiguration -> Bool
$c/= :: UpdateGameConfiguration -> UpdateGameConfiguration -> Bool
== :: UpdateGameConfiguration -> UpdateGameConfiguration -> Bool
$c== :: UpdateGameConfiguration -> UpdateGameConfiguration -> Bool
Prelude.Eq, ReadPrec [UpdateGameConfiguration]
ReadPrec UpdateGameConfiguration
Int -> ReadS UpdateGameConfiguration
ReadS [UpdateGameConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGameConfiguration]
$creadListPrec :: ReadPrec [UpdateGameConfiguration]
readPrec :: ReadPrec UpdateGameConfiguration
$creadPrec :: ReadPrec UpdateGameConfiguration
readList :: ReadS [UpdateGameConfiguration]
$creadList :: ReadS [UpdateGameConfiguration]
readsPrec :: Int -> ReadS UpdateGameConfiguration
$creadsPrec :: Int -> ReadS UpdateGameConfiguration
Prelude.Read, Int -> UpdateGameConfiguration -> ShowS
[UpdateGameConfiguration] -> ShowS
UpdateGameConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGameConfiguration] -> ShowS
$cshowList :: [UpdateGameConfiguration] -> ShowS
show :: UpdateGameConfiguration -> String
$cshow :: UpdateGameConfiguration -> String
showsPrec :: Int -> UpdateGameConfiguration -> ShowS
$cshowsPrec :: Int -> UpdateGameConfiguration -> ShowS
Prelude.Show, forall x. Rep UpdateGameConfiguration x -> UpdateGameConfiguration
forall x. UpdateGameConfiguration -> Rep UpdateGameConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateGameConfiguration x -> UpdateGameConfiguration
$cfrom :: forall x. UpdateGameConfiguration -> Rep UpdateGameConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGameConfiguration' 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:
--
-- 'gameName', 'updateGameConfiguration_gameName' - The name of the game.
--
-- 'modifications', 'updateGameConfiguration_modifications' - The list of modifications to make.
newUpdateGameConfiguration ::
  -- | 'gameName'
  Prelude.Text ->
  -- | 'modifications'
  Prelude.NonEmpty SectionModification ->
  UpdateGameConfiguration
newUpdateGameConfiguration :: Text -> NonEmpty SectionModification -> UpdateGameConfiguration
newUpdateGameConfiguration Text
pGameName_ NonEmpty SectionModification
pModifications_ =
  UpdateGameConfiguration'
    { $sel:gameName:UpdateGameConfiguration' :: Text
gameName = Text
pGameName_,
      $sel:modifications:UpdateGameConfiguration' :: NonEmpty SectionModification
modifications =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty SectionModification
pModifications_
    }

-- | The name of the game.
updateGameConfiguration_gameName :: Lens.Lens' UpdateGameConfiguration Prelude.Text
updateGameConfiguration_gameName :: Lens' UpdateGameConfiguration Text
updateGameConfiguration_gameName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGameConfiguration' {Text
gameName :: Text
$sel:gameName:UpdateGameConfiguration' :: UpdateGameConfiguration -> Text
gameName} -> Text
gameName) (\s :: UpdateGameConfiguration
s@UpdateGameConfiguration' {} Text
a -> UpdateGameConfiguration
s {$sel:gameName:UpdateGameConfiguration' :: Text
gameName = Text
a} :: UpdateGameConfiguration)

-- | The list of modifications to make.
updateGameConfiguration_modifications :: Lens.Lens' UpdateGameConfiguration (Prelude.NonEmpty SectionModification)
updateGameConfiguration_modifications :: Lens' UpdateGameConfiguration (NonEmpty SectionModification)
updateGameConfiguration_modifications = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGameConfiguration' {NonEmpty SectionModification
modifications :: NonEmpty SectionModification
$sel:modifications:UpdateGameConfiguration' :: UpdateGameConfiguration -> NonEmpty SectionModification
modifications} -> NonEmpty SectionModification
modifications) (\s :: UpdateGameConfiguration
s@UpdateGameConfiguration' {} NonEmpty SectionModification
a -> UpdateGameConfiguration
s {$sel:modifications:UpdateGameConfiguration' :: NonEmpty SectionModification
modifications = NonEmpty SectionModification
a} :: UpdateGameConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateGameConfiguration where
  type
    AWSResponse UpdateGameConfiguration =
      UpdateGameConfigurationResponse
  request :: (Service -> Service)
-> UpdateGameConfiguration -> Request UpdateGameConfiguration
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateGameConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateGameConfiguration)))
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 GameConfigurationDetails
-> Int -> UpdateGameConfigurationResponse
UpdateGameConfigurationResponse'
            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
"GameConfiguration")
            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 UpdateGameConfiguration where
  hashWithSalt :: Int -> UpdateGameConfiguration -> Int
hashWithSalt Int
_salt UpdateGameConfiguration' {NonEmpty SectionModification
Text
modifications :: NonEmpty SectionModification
gameName :: Text
$sel:modifications:UpdateGameConfiguration' :: UpdateGameConfiguration -> NonEmpty SectionModification
$sel:gameName:UpdateGameConfiguration' :: UpdateGameConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gameName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty SectionModification
modifications

instance Prelude.NFData UpdateGameConfiguration where
  rnf :: UpdateGameConfiguration -> ()
rnf UpdateGameConfiguration' {NonEmpty SectionModification
Text
modifications :: NonEmpty SectionModification
gameName :: Text
$sel:modifications:UpdateGameConfiguration' :: UpdateGameConfiguration -> NonEmpty SectionModification
$sel:gameName:UpdateGameConfiguration' :: UpdateGameConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
gameName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty SectionModification
modifications

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

instance Data.ToJSON UpdateGameConfiguration where
  toJSON :: UpdateGameConfiguration -> Value
toJSON UpdateGameConfiguration' {NonEmpty SectionModification
Text
modifications :: NonEmpty SectionModification
gameName :: Text
$sel:modifications:UpdateGameConfiguration' :: UpdateGameConfiguration -> NonEmpty SectionModification
$sel:gameName:UpdateGameConfiguration' :: UpdateGameConfiguration -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"Modifications" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty SectionModification
modifications)
          ]
      )

instance Data.ToPath UpdateGameConfiguration where
  toPath :: UpdateGameConfiguration -> ByteString
toPath UpdateGameConfiguration' {NonEmpty SectionModification
Text
modifications :: NonEmpty SectionModification
gameName :: Text
$sel:modifications:UpdateGameConfiguration' :: UpdateGameConfiguration -> NonEmpty SectionModification
$sel:gameName:UpdateGameConfiguration' :: UpdateGameConfiguration -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/game/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
gameName, ByteString
"/configuration"]

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

-- | /See:/ 'newUpdateGameConfigurationResponse' smart constructor.
data UpdateGameConfigurationResponse = UpdateGameConfigurationResponse'
  { -- | Details about the game configuration.
    UpdateGameConfigurationResponse -> Maybe GameConfigurationDetails
gameConfiguration :: Prelude.Maybe GameConfigurationDetails,
    -- | The response's http status code.
    UpdateGameConfigurationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateGameConfigurationResponse
-> UpdateGameConfigurationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGameConfigurationResponse
-> UpdateGameConfigurationResponse -> Bool
$c/= :: UpdateGameConfigurationResponse
-> UpdateGameConfigurationResponse -> Bool
== :: UpdateGameConfigurationResponse
-> UpdateGameConfigurationResponse -> Bool
$c== :: UpdateGameConfigurationResponse
-> UpdateGameConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [UpdateGameConfigurationResponse]
ReadPrec UpdateGameConfigurationResponse
Int -> ReadS UpdateGameConfigurationResponse
ReadS [UpdateGameConfigurationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGameConfigurationResponse]
$creadListPrec :: ReadPrec [UpdateGameConfigurationResponse]
readPrec :: ReadPrec UpdateGameConfigurationResponse
$creadPrec :: ReadPrec UpdateGameConfigurationResponse
readList :: ReadS [UpdateGameConfigurationResponse]
$creadList :: ReadS [UpdateGameConfigurationResponse]
readsPrec :: Int -> ReadS UpdateGameConfigurationResponse
$creadsPrec :: Int -> ReadS UpdateGameConfigurationResponse
Prelude.Read, Int -> UpdateGameConfigurationResponse -> ShowS
[UpdateGameConfigurationResponse] -> ShowS
UpdateGameConfigurationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGameConfigurationResponse] -> ShowS
$cshowList :: [UpdateGameConfigurationResponse] -> ShowS
show :: UpdateGameConfigurationResponse -> String
$cshow :: UpdateGameConfigurationResponse -> String
showsPrec :: Int -> UpdateGameConfigurationResponse -> ShowS
$cshowsPrec :: Int -> UpdateGameConfigurationResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateGameConfigurationResponse x
-> UpdateGameConfigurationResponse
forall x.
UpdateGameConfigurationResponse
-> Rep UpdateGameConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateGameConfigurationResponse x
-> UpdateGameConfigurationResponse
$cfrom :: forall x.
UpdateGameConfigurationResponse
-> Rep UpdateGameConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGameConfigurationResponse' 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:
--
-- 'gameConfiguration', 'updateGameConfigurationResponse_gameConfiguration' - Details about the game configuration.
--
-- 'httpStatus', 'updateGameConfigurationResponse_httpStatus' - The response's http status code.
newUpdateGameConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateGameConfigurationResponse
newUpdateGameConfigurationResponse :: Int -> UpdateGameConfigurationResponse
newUpdateGameConfigurationResponse Int
pHttpStatus_ =
  UpdateGameConfigurationResponse'
    { $sel:gameConfiguration:UpdateGameConfigurationResponse' :: Maybe GameConfigurationDetails
gameConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateGameConfigurationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details about the game configuration.
updateGameConfigurationResponse_gameConfiguration :: Lens.Lens' UpdateGameConfigurationResponse (Prelude.Maybe GameConfigurationDetails)
updateGameConfigurationResponse_gameConfiguration :: Lens'
  UpdateGameConfigurationResponse (Maybe GameConfigurationDetails)
updateGameConfigurationResponse_gameConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGameConfigurationResponse' {Maybe GameConfigurationDetails
gameConfiguration :: Maybe GameConfigurationDetails
$sel:gameConfiguration:UpdateGameConfigurationResponse' :: UpdateGameConfigurationResponse -> Maybe GameConfigurationDetails
gameConfiguration} -> Maybe GameConfigurationDetails
gameConfiguration) (\s :: UpdateGameConfigurationResponse
s@UpdateGameConfigurationResponse' {} Maybe GameConfigurationDetails
a -> UpdateGameConfigurationResponse
s {$sel:gameConfiguration:UpdateGameConfigurationResponse' :: Maybe GameConfigurationDetails
gameConfiguration = Maybe GameConfigurationDetails
a} :: UpdateGameConfigurationResponse)

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

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