{-# 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.GetGameConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the configuration of the game.
module Amazonka.GamesParks.GetGameConfiguration
  ( -- * Creating a Request
    GetGameConfiguration (..),
    newGetGameConfiguration,

    -- * Request Lenses
    getGameConfiguration_sections,
    getGameConfiguration_gameName,

    -- * Destructuring the Response
    GetGameConfigurationResponse (..),
    newGetGameConfigurationResponse,

    -- * Response Lenses
    getGameConfigurationResponse_gameConfiguration,
    getGameConfigurationResponse_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:/ 'newGetGameConfiguration' smart constructor.
data GetGameConfiguration = GetGameConfiguration'
  { -- | The list of sections to return.
    GetGameConfiguration -> Maybe (NonEmpty Text)
sections :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The name of the game.
    GetGameConfiguration -> Text
gameName :: Prelude.Text
  }
  deriving (GetGameConfiguration -> GetGameConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetGameConfiguration -> GetGameConfiguration -> Bool
$c/= :: GetGameConfiguration -> GetGameConfiguration -> Bool
== :: GetGameConfiguration -> GetGameConfiguration -> Bool
$c== :: GetGameConfiguration -> GetGameConfiguration -> Bool
Prelude.Eq, ReadPrec [GetGameConfiguration]
ReadPrec GetGameConfiguration
Int -> ReadS GetGameConfiguration
ReadS [GetGameConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetGameConfiguration]
$creadListPrec :: ReadPrec [GetGameConfiguration]
readPrec :: ReadPrec GetGameConfiguration
$creadPrec :: ReadPrec GetGameConfiguration
readList :: ReadS [GetGameConfiguration]
$creadList :: ReadS [GetGameConfiguration]
readsPrec :: Int -> ReadS GetGameConfiguration
$creadsPrec :: Int -> ReadS GetGameConfiguration
Prelude.Read, Int -> GetGameConfiguration -> ShowS
[GetGameConfiguration] -> ShowS
GetGameConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetGameConfiguration] -> ShowS
$cshowList :: [GetGameConfiguration] -> ShowS
show :: GetGameConfiguration -> String
$cshow :: GetGameConfiguration -> String
showsPrec :: Int -> GetGameConfiguration -> ShowS
$cshowsPrec :: Int -> GetGameConfiguration -> ShowS
Prelude.Show, forall x. Rep GetGameConfiguration x -> GetGameConfiguration
forall x. GetGameConfiguration -> Rep GetGameConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetGameConfiguration x -> GetGameConfiguration
$cfrom :: forall x. GetGameConfiguration -> Rep GetGameConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'GetGameConfiguration' 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:
--
-- 'sections', 'getGameConfiguration_sections' - The list of sections to return.
--
-- 'gameName', 'getGameConfiguration_gameName' - The name of the game.
newGetGameConfiguration ::
  -- | 'gameName'
  Prelude.Text ->
  GetGameConfiguration
newGetGameConfiguration :: Text -> GetGameConfiguration
newGetGameConfiguration Text
pGameName_ =
  GetGameConfiguration'
    { $sel:sections:GetGameConfiguration' :: Maybe (NonEmpty Text)
sections = forall a. Maybe a
Prelude.Nothing,
      $sel:gameName:GetGameConfiguration' :: Text
gameName = Text
pGameName_
    }

-- | The list of sections to return.
getGameConfiguration_sections :: Lens.Lens' GetGameConfiguration (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
getGameConfiguration_sections :: Lens' GetGameConfiguration (Maybe (NonEmpty Text))
getGameConfiguration_sections = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGameConfiguration' {Maybe (NonEmpty Text)
sections :: Maybe (NonEmpty Text)
$sel:sections:GetGameConfiguration' :: GetGameConfiguration -> Maybe (NonEmpty Text)
sections} -> Maybe (NonEmpty Text)
sections) (\s :: GetGameConfiguration
s@GetGameConfiguration' {} Maybe (NonEmpty Text)
a -> GetGameConfiguration
s {$sel:sections:GetGameConfiguration' :: Maybe (NonEmpty Text)
sections = Maybe (NonEmpty Text)
a} :: GetGameConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Core.AWSRequest GetGameConfiguration where
  type
    AWSResponse GetGameConfiguration =
      GetGameConfigurationResponse
  request :: (Service -> Service)
-> GetGameConfiguration -> Request GetGameConfiguration
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetGameConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetGameConfiguration)))
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 -> GetGameConfigurationResponse
GetGameConfigurationResponse'
            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 GetGameConfiguration where
  hashWithSalt :: Int -> GetGameConfiguration -> Int
hashWithSalt Int
_salt GetGameConfiguration' {Maybe (NonEmpty Text)
Text
gameName :: Text
sections :: Maybe (NonEmpty Text)
$sel:gameName:GetGameConfiguration' :: GetGameConfiguration -> Text
$sel:sections:GetGameConfiguration' :: GetGameConfiguration -> Maybe (NonEmpty Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
sections
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gameName

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

instance Data.ToHeaders GetGameConfiguration where
  toHeaders :: GetGameConfiguration -> 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.ToPath GetGameConfiguration where
  toPath :: GetGameConfiguration -> ByteString
toPath GetGameConfiguration' {Maybe (NonEmpty Text)
Text
gameName :: Text
sections :: Maybe (NonEmpty Text)
$sel:gameName:GetGameConfiguration' :: GetGameConfiguration -> Text
$sel:sections:GetGameConfiguration' :: GetGameConfiguration -> Maybe (NonEmpty 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 GetGameConfiguration where
  toQuery :: GetGameConfiguration -> QueryString
toQuery GetGameConfiguration' {Maybe (NonEmpty Text)
Text
gameName :: Text
sections :: Maybe (NonEmpty Text)
$sel:gameName:GetGameConfiguration' :: GetGameConfiguration -> Text
$sel:sections:GetGameConfiguration' :: GetGameConfiguration -> Maybe (NonEmpty Text)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Sections"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
sections)
      ]

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

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

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

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

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