{-# 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.ImportGameConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Imports a game configuration.
--
-- This operation replaces the current configuration of the game with the
-- provided input. This is not a reversible operation. If you want to
-- preserve the previous configuration, use @CreateSnapshot@ to make a new
-- snapshot before importing.
module Amazonka.GamesParks.ImportGameConfiguration
  ( -- * Creating a Request
    ImportGameConfiguration (..),
    newImportGameConfiguration,

    -- * Request Lenses
    importGameConfiguration_gameName,
    importGameConfiguration_importSource,

    -- * Destructuring the Response
    ImportGameConfigurationResponse (..),
    newImportGameConfigurationResponse,

    -- * Response Lenses
    importGameConfigurationResponse_gameConfiguration,
    importGameConfigurationResponse_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:/ 'newImportGameConfiguration' smart constructor.
data ImportGameConfiguration = ImportGameConfiguration'
  { -- | The name of the game.
    ImportGameConfiguration -> Text
gameName :: Prelude.Text,
    -- | The source used to import configuration sections.
    ImportGameConfiguration -> ImportGameConfigurationSource
importSource :: ImportGameConfigurationSource
  }
  deriving (ImportGameConfiguration -> ImportGameConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportGameConfiguration -> ImportGameConfiguration -> Bool
$c/= :: ImportGameConfiguration -> ImportGameConfiguration -> Bool
== :: ImportGameConfiguration -> ImportGameConfiguration -> Bool
$c== :: ImportGameConfiguration -> ImportGameConfiguration -> Bool
Prelude.Eq, ReadPrec [ImportGameConfiguration]
ReadPrec ImportGameConfiguration
Int -> ReadS ImportGameConfiguration
ReadS [ImportGameConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportGameConfiguration]
$creadListPrec :: ReadPrec [ImportGameConfiguration]
readPrec :: ReadPrec ImportGameConfiguration
$creadPrec :: ReadPrec ImportGameConfiguration
readList :: ReadS [ImportGameConfiguration]
$creadList :: ReadS [ImportGameConfiguration]
readsPrec :: Int -> ReadS ImportGameConfiguration
$creadsPrec :: Int -> ReadS ImportGameConfiguration
Prelude.Read, Int -> ImportGameConfiguration -> ShowS
[ImportGameConfiguration] -> ShowS
ImportGameConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportGameConfiguration] -> ShowS
$cshowList :: [ImportGameConfiguration] -> ShowS
show :: ImportGameConfiguration -> String
$cshow :: ImportGameConfiguration -> String
showsPrec :: Int -> ImportGameConfiguration -> ShowS
$cshowsPrec :: Int -> ImportGameConfiguration -> ShowS
Prelude.Show, forall x. Rep ImportGameConfiguration x -> ImportGameConfiguration
forall x. ImportGameConfiguration -> Rep ImportGameConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportGameConfiguration x -> ImportGameConfiguration
$cfrom :: forall x. ImportGameConfiguration -> Rep ImportGameConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ImportGameConfiguration' 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', 'importGameConfiguration_gameName' - The name of the game.
--
-- 'importSource', 'importGameConfiguration_importSource' - The source used to import configuration sections.
newImportGameConfiguration ::
  -- | 'gameName'
  Prelude.Text ->
  -- | 'importSource'
  ImportGameConfigurationSource ->
  ImportGameConfiguration
newImportGameConfiguration :: Text -> ImportGameConfigurationSource -> ImportGameConfiguration
newImportGameConfiguration Text
pGameName_ ImportGameConfigurationSource
pImportSource_ =
  ImportGameConfiguration'
    { $sel:gameName:ImportGameConfiguration' :: Text
gameName = Text
pGameName_,
      $sel:importSource:ImportGameConfiguration' :: ImportGameConfigurationSource
importSource = ImportGameConfigurationSource
pImportSource_
    }

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

-- | The source used to import configuration sections.
importGameConfiguration_importSource :: Lens.Lens' ImportGameConfiguration ImportGameConfigurationSource
importGameConfiguration_importSource :: Lens' ImportGameConfiguration ImportGameConfigurationSource
importGameConfiguration_importSource = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportGameConfiguration' {ImportGameConfigurationSource
importSource :: ImportGameConfigurationSource
$sel:importSource:ImportGameConfiguration' :: ImportGameConfiguration -> ImportGameConfigurationSource
importSource} -> ImportGameConfigurationSource
importSource) (\s :: ImportGameConfiguration
s@ImportGameConfiguration' {} ImportGameConfigurationSource
a -> ImportGameConfiguration
s {$sel:importSource:ImportGameConfiguration' :: ImportGameConfigurationSource
importSource = ImportGameConfigurationSource
a} :: ImportGameConfiguration)

instance Core.AWSRequest ImportGameConfiguration where
  type
    AWSResponse ImportGameConfiguration =
      ImportGameConfigurationResponse
  request :: (Service -> Service)
-> ImportGameConfiguration -> Request ImportGameConfiguration
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ImportGameConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ImportGameConfiguration)))
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 -> ImportGameConfigurationResponse
ImportGameConfigurationResponse'
            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 ImportGameConfiguration where
  hashWithSalt :: Int -> ImportGameConfiguration -> Int
hashWithSalt Int
_salt ImportGameConfiguration' {Text
ImportGameConfigurationSource
importSource :: ImportGameConfigurationSource
gameName :: Text
$sel:importSource:ImportGameConfiguration' :: ImportGameConfiguration -> ImportGameConfigurationSource
$sel:gameName:ImportGameConfiguration' :: ImportGameConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gameName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ImportGameConfigurationSource
importSource

instance Prelude.NFData ImportGameConfiguration where
  rnf :: ImportGameConfiguration -> ()
rnf ImportGameConfiguration' {Text
ImportGameConfigurationSource
importSource :: ImportGameConfigurationSource
gameName :: Text
$sel:importSource:ImportGameConfiguration' :: ImportGameConfiguration -> ImportGameConfigurationSource
$sel:gameName:ImportGameConfiguration' :: ImportGameConfiguration -> 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 ImportGameConfigurationSource
importSource

instance Data.ToHeaders ImportGameConfiguration where
  toHeaders :: ImportGameConfiguration -> 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 ImportGameConfiguration where
  toJSON :: ImportGameConfiguration -> Value
toJSON ImportGameConfiguration' {Text
ImportGameConfigurationSource
importSource :: ImportGameConfigurationSource
gameName :: Text
$sel:importSource:ImportGameConfiguration' :: ImportGameConfiguration -> ImportGameConfigurationSource
$sel:gameName:ImportGameConfiguration' :: ImportGameConfiguration -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ImportSource" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ImportGameConfigurationSource
importSource)]
      )

instance Data.ToPath ImportGameConfiguration where
  toPath :: ImportGameConfiguration -> ByteString
toPath ImportGameConfiguration' {Text
ImportGameConfigurationSource
importSource :: ImportGameConfigurationSource
gameName :: Text
$sel:importSource:ImportGameConfiguration' :: ImportGameConfiguration -> ImportGameConfigurationSource
$sel:gameName:ImportGameConfiguration' :: ImportGameConfiguration -> 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 ImportGameConfiguration where
  toQuery :: ImportGameConfiguration -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

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

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

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

instance
  Prelude.NFData
    ImportGameConfigurationResponse
  where
  rnf :: ImportGameConfigurationResponse -> ()
rnf ImportGameConfigurationResponse' {Int
Maybe GameConfigurationDetails
httpStatus :: Int
gameConfiguration :: Maybe GameConfigurationDetails
$sel:httpStatus:ImportGameConfigurationResponse' :: ImportGameConfigurationResponse -> Int
$sel:gameConfiguration:ImportGameConfigurationResponse' :: ImportGameConfigurationResponse -> 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