{-# 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.DescribeGameSessionPlacement
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves information, including current status, about a game session
-- placement request.
--
-- To get game session placement details, specify the placement ID.
--
-- If successful, a GameSessionPlacement object is returned.
--
-- __Related actions__
--
-- CreateGameSession | DescribeGameSessions | DescribeGameSessionDetails |
-- SearchGameSessions | UpdateGameSession | GetGameSessionLogUrl |
-- StartGameSessionPlacement | DescribeGameSessionPlacement |
-- StopGameSessionPlacement |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
module Amazonka.GameLift.DescribeGameSessionPlacement
  ( -- * Creating a Request
    DescribeGameSessionPlacement (..),
    newDescribeGameSessionPlacement,

    -- * Request Lenses
    describeGameSessionPlacement_placementId,

    -- * Destructuring the Response
    DescribeGameSessionPlacementResponse (..),
    newDescribeGameSessionPlacementResponse,

    -- * Response Lenses
    describeGameSessionPlacementResponse_gameSessionPlacement,
    describeGameSessionPlacementResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GameLift.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input for a request operation.
--
-- /See:/ 'newDescribeGameSessionPlacement' smart constructor.
data DescribeGameSessionPlacement = DescribeGameSessionPlacement'
  { -- | A unique identifier for a game session placement to retrieve.
    DescribeGameSessionPlacement -> Text
placementId :: Prelude.Text
  }
  deriving (DescribeGameSessionPlacement
-> DescribeGameSessionPlacement -> Bool
(DescribeGameSessionPlacement
 -> DescribeGameSessionPlacement -> Bool)
-> (DescribeGameSessionPlacement
    -> DescribeGameSessionPlacement -> Bool)
-> Eq DescribeGameSessionPlacement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGameSessionPlacement
-> DescribeGameSessionPlacement -> Bool
$c/= :: DescribeGameSessionPlacement
-> DescribeGameSessionPlacement -> Bool
== :: DescribeGameSessionPlacement
-> DescribeGameSessionPlacement -> Bool
$c== :: DescribeGameSessionPlacement
-> DescribeGameSessionPlacement -> Bool
Prelude.Eq, ReadPrec [DescribeGameSessionPlacement]
ReadPrec DescribeGameSessionPlacement
Int -> ReadS DescribeGameSessionPlacement
ReadS [DescribeGameSessionPlacement]
(Int -> ReadS DescribeGameSessionPlacement)
-> ReadS [DescribeGameSessionPlacement]
-> ReadPrec DescribeGameSessionPlacement
-> ReadPrec [DescribeGameSessionPlacement]
-> Read DescribeGameSessionPlacement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGameSessionPlacement]
$creadListPrec :: ReadPrec [DescribeGameSessionPlacement]
readPrec :: ReadPrec DescribeGameSessionPlacement
$creadPrec :: ReadPrec DescribeGameSessionPlacement
readList :: ReadS [DescribeGameSessionPlacement]
$creadList :: ReadS [DescribeGameSessionPlacement]
readsPrec :: Int -> ReadS DescribeGameSessionPlacement
$creadsPrec :: Int -> ReadS DescribeGameSessionPlacement
Prelude.Read, Int -> DescribeGameSessionPlacement -> ShowS
[DescribeGameSessionPlacement] -> ShowS
DescribeGameSessionPlacement -> String
(Int -> DescribeGameSessionPlacement -> ShowS)
-> (DescribeGameSessionPlacement -> String)
-> ([DescribeGameSessionPlacement] -> ShowS)
-> Show DescribeGameSessionPlacement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGameSessionPlacement] -> ShowS
$cshowList :: [DescribeGameSessionPlacement] -> ShowS
show :: DescribeGameSessionPlacement -> String
$cshow :: DescribeGameSessionPlacement -> String
showsPrec :: Int -> DescribeGameSessionPlacement -> ShowS
$cshowsPrec :: Int -> DescribeGameSessionPlacement -> ShowS
Prelude.Show, (forall x.
 DescribeGameSessionPlacement -> Rep DescribeGameSessionPlacement x)
-> (forall x.
    Rep DescribeGameSessionPlacement x -> DescribeGameSessionPlacement)
-> Generic DescribeGameSessionPlacement
forall x.
Rep DescribeGameSessionPlacement x -> DescribeGameSessionPlacement
forall x.
DescribeGameSessionPlacement -> Rep DescribeGameSessionPlacement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeGameSessionPlacement x -> DescribeGameSessionPlacement
$cfrom :: forall x.
DescribeGameSessionPlacement -> Rep DescribeGameSessionPlacement x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGameSessionPlacement' 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:
--
-- 'placementId', 'describeGameSessionPlacement_placementId' - A unique identifier for a game session placement to retrieve.
newDescribeGameSessionPlacement ::
  -- | 'placementId'
  Prelude.Text ->
  DescribeGameSessionPlacement
newDescribeGameSessionPlacement :: Text -> DescribeGameSessionPlacement
newDescribeGameSessionPlacement Text
pPlacementId_ =
  DescribeGameSessionPlacement' :: Text -> DescribeGameSessionPlacement
DescribeGameSessionPlacement'
    { $sel:placementId:DescribeGameSessionPlacement' :: Text
placementId =
        Text
pPlacementId_
    }

-- | A unique identifier for a game session placement to retrieve.
describeGameSessionPlacement_placementId :: Lens.Lens' DescribeGameSessionPlacement Prelude.Text
describeGameSessionPlacement_placementId :: (Text -> f Text)
-> DescribeGameSessionPlacement -> f DescribeGameSessionPlacement
describeGameSessionPlacement_placementId = (DescribeGameSessionPlacement -> Text)
-> (DescribeGameSessionPlacement
    -> Text -> DescribeGameSessionPlacement)
-> Lens
     DescribeGameSessionPlacement DescribeGameSessionPlacement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameSessionPlacement' {Text
placementId :: Text
$sel:placementId:DescribeGameSessionPlacement' :: DescribeGameSessionPlacement -> Text
placementId} -> Text
placementId) (\s :: DescribeGameSessionPlacement
s@DescribeGameSessionPlacement' {} Text
a -> DescribeGameSessionPlacement
s {$sel:placementId:DescribeGameSessionPlacement' :: Text
placementId = Text
a} :: DescribeGameSessionPlacement)

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

instance
  Prelude.Hashable
    DescribeGameSessionPlacement

instance Prelude.NFData DescribeGameSessionPlacement

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

instance Core.ToJSON DescribeGameSessionPlacement where
  toJSON :: DescribeGameSessionPlacement -> Value
toJSON DescribeGameSessionPlacement' {Text
placementId :: Text
$sel:placementId:DescribeGameSessionPlacement' :: DescribeGameSessionPlacement -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PlacementId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
placementId)]
      )

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

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

-- | Represents the returned data in response to a request operation.
--
-- /See:/ 'newDescribeGameSessionPlacementResponse' smart constructor.
data DescribeGameSessionPlacementResponse = DescribeGameSessionPlacementResponse'
  { -- | Object that describes the requested game session placement.
    DescribeGameSessionPlacementResponse -> Maybe GameSessionPlacement
gameSessionPlacement :: Prelude.Maybe GameSessionPlacement,
    -- | The response's http status code.
    DescribeGameSessionPlacementResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeGameSessionPlacementResponse
-> DescribeGameSessionPlacementResponse -> Bool
(DescribeGameSessionPlacementResponse
 -> DescribeGameSessionPlacementResponse -> Bool)
-> (DescribeGameSessionPlacementResponse
    -> DescribeGameSessionPlacementResponse -> Bool)
-> Eq DescribeGameSessionPlacementResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGameSessionPlacementResponse
-> DescribeGameSessionPlacementResponse -> Bool
$c/= :: DescribeGameSessionPlacementResponse
-> DescribeGameSessionPlacementResponse -> Bool
== :: DescribeGameSessionPlacementResponse
-> DescribeGameSessionPlacementResponse -> Bool
$c== :: DescribeGameSessionPlacementResponse
-> DescribeGameSessionPlacementResponse -> Bool
Prelude.Eq, ReadPrec [DescribeGameSessionPlacementResponse]
ReadPrec DescribeGameSessionPlacementResponse
Int -> ReadS DescribeGameSessionPlacementResponse
ReadS [DescribeGameSessionPlacementResponse]
(Int -> ReadS DescribeGameSessionPlacementResponse)
-> ReadS [DescribeGameSessionPlacementResponse]
-> ReadPrec DescribeGameSessionPlacementResponse
-> ReadPrec [DescribeGameSessionPlacementResponse]
-> Read DescribeGameSessionPlacementResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGameSessionPlacementResponse]
$creadListPrec :: ReadPrec [DescribeGameSessionPlacementResponse]
readPrec :: ReadPrec DescribeGameSessionPlacementResponse
$creadPrec :: ReadPrec DescribeGameSessionPlacementResponse
readList :: ReadS [DescribeGameSessionPlacementResponse]
$creadList :: ReadS [DescribeGameSessionPlacementResponse]
readsPrec :: Int -> ReadS DescribeGameSessionPlacementResponse
$creadsPrec :: Int -> ReadS DescribeGameSessionPlacementResponse
Prelude.Read, Int -> DescribeGameSessionPlacementResponse -> ShowS
[DescribeGameSessionPlacementResponse] -> ShowS
DescribeGameSessionPlacementResponse -> String
(Int -> DescribeGameSessionPlacementResponse -> ShowS)
-> (DescribeGameSessionPlacementResponse -> String)
-> ([DescribeGameSessionPlacementResponse] -> ShowS)
-> Show DescribeGameSessionPlacementResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGameSessionPlacementResponse] -> ShowS
$cshowList :: [DescribeGameSessionPlacementResponse] -> ShowS
show :: DescribeGameSessionPlacementResponse -> String
$cshow :: DescribeGameSessionPlacementResponse -> String
showsPrec :: Int -> DescribeGameSessionPlacementResponse -> ShowS
$cshowsPrec :: Int -> DescribeGameSessionPlacementResponse -> ShowS
Prelude.Show, (forall x.
 DescribeGameSessionPlacementResponse
 -> Rep DescribeGameSessionPlacementResponse x)
-> (forall x.
    Rep DescribeGameSessionPlacementResponse x
    -> DescribeGameSessionPlacementResponse)
-> Generic DescribeGameSessionPlacementResponse
forall x.
Rep DescribeGameSessionPlacementResponse x
-> DescribeGameSessionPlacementResponse
forall x.
DescribeGameSessionPlacementResponse
-> Rep DescribeGameSessionPlacementResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeGameSessionPlacementResponse x
-> DescribeGameSessionPlacementResponse
$cfrom :: forall x.
DescribeGameSessionPlacementResponse
-> Rep DescribeGameSessionPlacementResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGameSessionPlacementResponse' 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:
--
-- 'gameSessionPlacement', 'describeGameSessionPlacementResponse_gameSessionPlacement' - Object that describes the requested game session placement.
--
-- 'httpStatus', 'describeGameSessionPlacementResponse_httpStatus' - The response's http status code.
newDescribeGameSessionPlacementResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeGameSessionPlacementResponse
newDescribeGameSessionPlacementResponse :: Int -> DescribeGameSessionPlacementResponse
newDescribeGameSessionPlacementResponse Int
pHttpStatus_ =
  DescribeGameSessionPlacementResponse' :: Maybe GameSessionPlacement
-> Int -> DescribeGameSessionPlacementResponse
DescribeGameSessionPlacementResponse'
    { $sel:gameSessionPlacement:DescribeGameSessionPlacementResponse' :: Maybe GameSessionPlacement
gameSessionPlacement =
        Maybe GameSessionPlacement
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeGameSessionPlacementResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Object that describes the requested game session placement.
describeGameSessionPlacementResponse_gameSessionPlacement :: Lens.Lens' DescribeGameSessionPlacementResponse (Prelude.Maybe GameSessionPlacement)
describeGameSessionPlacementResponse_gameSessionPlacement :: (Maybe GameSessionPlacement -> f (Maybe GameSessionPlacement))
-> DescribeGameSessionPlacementResponse
-> f DescribeGameSessionPlacementResponse
describeGameSessionPlacementResponse_gameSessionPlacement = (DescribeGameSessionPlacementResponse
 -> Maybe GameSessionPlacement)
-> (DescribeGameSessionPlacementResponse
    -> Maybe GameSessionPlacement
    -> DescribeGameSessionPlacementResponse)
-> Lens
     DescribeGameSessionPlacementResponse
     DescribeGameSessionPlacementResponse
     (Maybe GameSessionPlacement)
     (Maybe GameSessionPlacement)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGameSessionPlacementResponse' {Maybe GameSessionPlacement
gameSessionPlacement :: Maybe GameSessionPlacement
$sel:gameSessionPlacement:DescribeGameSessionPlacementResponse' :: DescribeGameSessionPlacementResponse -> Maybe GameSessionPlacement
gameSessionPlacement} -> Maybe GameSessionPlacement
gameSessionPlacement) (\s :: DescribeGameSessionPlacementResponse
s@DescribeGameSessionPlacementResponse' {} Maybe GameSessionPlacement
a -> DescribeGameSessionPlacementResponse
s {$sel:gameSessionPlacement:DescribeGameSessionPlacementResponse' :: Maybe GameSessionPlacement
gameSessionPlacement = Maybe GameSessionPlacement
a} :: DescribeGameSessionPlacementResponse)

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

instance
  Prelude.NFData
    DescribeGameSessionPlacementResponse