{-# 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.GetGame
-- 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 details about a game.
module Amazonka.GamesParks.GetGame
  ( -- * Creating a Request
    GetGame (..),
    newGetGame,

    -- * Request Lenses
    getGame_gameName,

    -- * Destructuring the Response
    GetGameResponse (..),
    newGetGameResponse,

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

-- |
-- Create a value of 'GetGame' 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', 'getGame_gameName' - The name of the game.
newGetGame ::
  -- | 'gameName'
  Prelude.Text ->
  GetGame
newGetGame :: Text -> GetGame
newGetGame Text
pGameName_ =
  GetGame' {$sel:gameName:GetGame' :: Text
gameName = Text
pGameName_}

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

instance Core.AWSRequest GetGame where
  type AWSResponse GetGame = GetGameResponse
  request :: (Service -> Service) -> GetGame -> Request GetGame
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 GetGame
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetGame)))
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 GameDetails -> Int -> GetGameResponse
GetGameResponse'
            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
"Game")
            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 GetGame where
  hashWithSalt :: Int -> GetGame -> Int
hashWithSalt Int
_salt GetGame' {Text
gameName :: Text
$sel:gameName:GetGame' :: GetGame -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gameName

instance Prelude.NFData GetGame where
  rnf :: GetGame -> ()
rnf GetGame' {Text
gameName :: Text
$sel:gameName:GetGame' :: GetGame -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
gameName

instance Data.ToHeaders GetGame where
  toHeaders :: GetGame -> 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 GetGame where
  toPath :: GetGame -> ByteString
toPath GetGame' {Text
gameName :: Text
$sel:gameName:GetGame' :: GetGame -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/game/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
gameName]

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

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

-- |
-- Create a value of 'GetGameResponse' 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:
--
-- 'game', 'getGameResponse_game' - The details of the game.
--
-- 'httpStatus', 'getGameResponse_httpStatus' - The response's http status code.
newGetGameResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetGameResponse
newGetGameResponse :: Int -> GetGameResponse
newGetGameResponse Int
pHttpStatus_ =
  GetGameResponse'
    { $sel:game:GetGameResponse' :: Maybe GameDetails
game = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetGameResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The details of the game.
getGameResponse_game :: Lens.Lens' GetGameResponse (Prelude.Maybe GameDetails)
getGameResponse_game :: Lens' GetGameResponse (Maybe GameDetails)
getGameResponse_game = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGameResponse' {Maybe GameDetails
game :: Maybe GameDetails
$sel:game:GetGameResponse' :: GetGameResponse -> Maybe GameDetails
game} -> Maybe GameDetails
game) (\s :: GetGameResponse
s@GetGameResponse' {} Maybe GameDetails
a -> GetGameResponse
s {$sel:game:GetGameResponse' :: Maybe GameDetails
game = Maybe GameDetails
a} :: GetGameResponse)

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

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