{-# 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.DescribeMatchmaking
-- 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 one or more matchmaking tickets. Use this operation to
-- retrieve ticket information, including--after a successful match is
-- made--connection information for the resulting new game session.
--
-- To request matchmaking tickets, provide a list of up to 10 ticket IDs.
-- If the request is successful, a ticket object is returned for each
-- requested ID that currently exists.
--
-- This operation is not designed to be continually called to track
-- matchmaking ticket status. This practice can cause you to exceed your
-- API limit, which results in errors. Instead, as a best practice, set up
-- an Amazon Simple Notification Service (SNS) to receive notifications,
-- and provide the topic ARN in the matchmaking configuration. Continuously
-- poling ticket status with DescribeMatchmaking should only be used for
-- games in development with low matchmaking usage.
--
-- __Learn more__
--
-- <https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-client.html Add FlexMatch to a game client>
--
-- <https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-notification.html Set Up FlexMatch event notification>
--
-- __Related actions__
--
-- StartMatchmaking | DescribeMatchmaking | StopMatchmaking | AcceptMatch |
-- StartMatchBackfill |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
module Amazonka.GameLift.DescribeMatchmaking
  ( -- * Creating a Request
    DescribeMatchmaking (..),
    newDescribeMatchmaking,

    -- * Request Lenses
    describeMatchmaking_ticketIds,

    -- * Destructuring the Response
    DescribeMatchmakingResponse (..),
    newDescribeMatchmakingResponse,

    -- * Response Lenses
    describeMatchmakingResponse_ticketList,
    describeMatchmakingResponse_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:/ 'newDescribeMatchmaking' smart constructor.
data DescribeMatchmaking = DescribeMatchmaking'
  { -- | A unique identifier for a matchmaking ticket. You can include up to 10
    -- ID values.
    DescribeMatchmaking -> [Text]
ticketIds :: [Prelude.Text]
  }
  deriving (DescribeMatchmaking -> DescribeMatchmaking -> Bool
(DescribeMatchmaking -> DescribeMatchmaking -> Bool)
-> (DescribeMatchmaking -> DescribeMatchmaking -> Bool)
-> Eq DescribeMatchmaking
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMatchmaking -> DescribeMatchmaking -> Bool
$c/= :: DescribeMatchmaking -> DescribeMatchmaking -> Bool
== :: DescribeMatchmaking -> DescribeMatchmaking -> Bool
$c== :: DescribeMatchmaking -> DescribeMatchmaking -> Bool
Prelude.Eq, ReadPrec [DescribeMatchmaking]
ReadPrec DescribeMatchmaking
Int -> ReadS DescribeMatchmaking
ReadS [DescribeMatchmaking]
(Int -> ReadS DescribeMatchmaking)
-> ReadS [DescribeMatchmaking]
-> ReadPrec DescribeMatchmaking
-> ReadPrec [DescribeMatchmaking]
-> Read DescribeMatchmaking
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMatchmaking]
$creadListPrec :: ReadPrec [DescribeMatchmaking]
readPrec :: ReadPrec DescribeMatchmaking
$creadPrec :: ReadPrec DescribeMatchmaking
readList :: ReadS [DescribeMatchmaking]
$creadList :: ReadS [DescribeMatchmaking]
readsPrec :: Int -> ReadS DescribeMatchmaking
$creadsPrec :: Int -> ReadS DescribeMatchmaking
Prelude.Read, Int -> DescribeMatchmaking -> ShowS
[DescribeMatchmaking] -> ShowS
DescribeMatchmaking -> String
(Int -> DescribeMatchmaking -> ShowS)
-> (DescribeMatchmaking -> String)
-> ([DescribeMatchmaking] -> ShowS)
-> Show DescribeMatchmaking
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMatchmaking] -> ShowS
$cshowList :: [DescribeMatchmaking] -> ShowS
show :: DescribeMatchmaking -> String
$cshow :: DescribeMatchmaking -> String
showsPrec :: Int -> DescribeMatchmaking -> ShowS
$cshowsPrec :: Int -> DescribeMatchmaking -> ShowS
Prelude.Show, (forall x. DescribeMatchmaking -> Rep DescribeMatchmaking x)
-> (forall x. Rep DescribeMatchmaking x -> DescribeMatchmaking)
-> Generic DescribeMatchmaking
forall x. Rep DescribeMatchmaking x -> DescribeMatchmaking
forall x. DescribeMatchmaking -> Rep DescribeMatchmaking x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeMatchmaking x -> DescribeMatchmaking
$cfrom :: forall x. DescribeMatchmaking -> Rep DescribeMatchmaking x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMatchmaking' 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:
--
-- 'ticketIds', 'describeMatchmaking_ticketIds' - A unique identifier for a matchmaking ticket. You can include up to 10
-- ID values.
newDescribeMatchmaking ::
  DescribeMatchmaking
newDescribeMatchmaking :: DescribeMatchmaking
newDescribeMatchmaking =
  DescribeMatchmaking' :: [Text] -> DescribeMatchmaking
DescribeMatchmaking' {$sel:ticketIds:DescribeMatchmaking' :: [Text]
ticketIds = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | A unique identifier for a matchmaking ticket. You can include up to 10
-- ID values.
describeMatchmaking_ticketIds :: Lens.Lens' DescribeMatchmaking [Prelude.Text]
describeMatchmaking_ticketIds :: ([Text] -> f [Text])
-> DescribeMatchmaking -> f DescribeMatchmaking
describeMatchmaking_ticketIds = (DescribeMatchmaking -> [Text])
-> (DescribeMatchmaking -> [Text] -> DescribeMatchmaking)
-> Lens DescribeMatchmaking DescribeMatchmaking [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMatchmaking' {[Text]
ticketIds :: [Text]
$sel:ticketIds:DescribeMatchmaking' :: DescribeMatchmaking -> [Text]
ticketIds} -> [Text]
ticketIds) (\s :: DescribeMatchmaking
s@DescribeMatchmaking' {} [Text]
a -> DescribeMatchmaking
s {$sel:ticketIds:DescribeMatchmaking' :: [Text]
ticketIds = [Text]
a} :: DescribeMatchmaking) (([Text] -> f [Text])
 -> DescribeMatchmaking -> f DescribeMatchmaking)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DescribeMatchmaking
-> f DescribeMatchmaking
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DescribeMatchmaking where
  type
    AWSResponse DescribeMatchmaking =
      DescribeMatchmakingResponse
  request :: DescribeMatchmaking -> Request DescribeMatchmaking
request = Service -> DescribeMatchmaking -> Request DescribeMatchmaking
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeMatchmaking
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeMatchmaking)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeMatchmaking))
-> Logger
-> Service
-> Proxy DescribeMatchmaking
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeMatchmaking)))
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 [MatchmakingTicket] -> Int -> DescribeMatchmakingResponse
DescribeMatchmakingResponse'
            (Maybe [MatchmakingTicket] -> Int -> DescribeMatchmakingResponse)
-> Either String (Maybe [MatchmakingTicket])
-> Either String (Int -> DescribeMatchmakingResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [MatchmakingTicket]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TicketList" Either String (Maybe (Maybe [MatchmakingTicket]))
-> Maybe [MatchmakingTicket]
-> Either String (Maybe [MatchmakingTicket])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [MatchmakingTicket]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DescribeMatchmakingResponse)
-> Either String Int -> Either String DescribeMatchmakingResponse
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 DescribeMatchmaking

instance Prelude.NFData DescribeMatchmaking

instance Core.ToHeaders DescribeMatchmaking where
  toHeaders :: DescribeMatchmaking -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeMatchmaking -> 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.DescribeMatchmaking" ::
                          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 DescribeMatchmaking where
  toJSON :: DescribeMatchmaking -> Value
toJSON DescribeMatchmaking' {[Text]
ticketIds :: [Text]
$sel:ticketIds:DescribeMatchmaking' :: DescribeMatchmaking -> [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
"TicketIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
ticketIds)]
      )

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

instance Core.ToQuery DescribeMatchmaking where
  toQuery :: DescribeMatchmaking -> QueryString
toQuery = QueryString -> DescribeMatchmaking -> 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:/ 'newDescribeMatchmakingResponse' smart constructor.
data DescribeMatchmakingResponse = DescribeMatchmakingResponse'
  { -- | A collection of existing matchmaking ticket objects matching the
    -- request.
    DescribeMatchmakingResponse -> Maybe [MatchmakingTicket]
ticketList :: Prelude.Maybe [MatchmakingTicket],
    -- | The response's http status code.
    DescribeMatchmakingResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeMatchmakingResponse -> DescribeMatchmakingResponse -> Bool
(DescribeMatchmakingResponse
 -> DescribeMatchmakingResponse -> Bool)
-> (DescribeMatchmakingResponse
    -> DescribeMatchmakingResponse -> Bool)
-> Eq DescribeMatchmakingResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMatchmakingResponse -> DescribeMatchmakingResponse -> Bool
$c/= :: DescribeMatchmakingResponse -> DescribeMatchmakingResponse -> Bool
== :: DescribeMatchmakingResponse -> DescribeMatchmakingResponse -> Bool
$c== :: DescribeMatchmakingResponse -> DescribeMatchmakingResponse -> Bool
Prelude.Eq, ReadPrec [DescribeMatchmakingResponse]
ReadPrec DescribeMatchmakingResponse
Int -> ReadS DescribeMatchmakingResponse
ReadS [DescribeMatchmakingResponse]
(Int -> ReadS DescribeMatchmakingResponse)
-> ReadS [DescribeMatchmakingResponse]
-> ReadPrec DescribeMatchmakingResponse
-> ReadPrec [DescribeMatchmakingResponse]
-> Read DescribeMatchmakingResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMatchmakingResponse]
$creadListPrec :: ReadPrec [DescribeMatchmakingResponse]
readPrec :: ReadPrec DescribeMatchmakingResponse
$creadPrec :: ReadPrec DescribeMatchmakingResponse
readList :: ReadS [DescribeMatchmakingResponse]
$creadList :: ReadS [DescribeMatchmakingResponse]
readsPrec :: Int -> ReadS DescribeMatchmakingResponse
$creadsPrec :: Int -> ReadS DescribeMatchmakingResponse
Prelude.Read, Int -> DescribeMatchmakingResponse -> ShowS
[DescribeMatchmakingResponse] -> ShowS
DescribeMatchmakingResponse -> String
(Int -> DescribeMatchmakingResponse -> ShowS)
-> (DescribeMatchmakingResponse -> String)
-> ([DescribeMatchmakingResponse] -> ShowS)
-> Show DescribeMatchmakingResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMatchmakingResponse] -> ShowS
$cshowList :: [DescribeMatchmakingResponse] -> ShowS
show :: DescribeMatchmakingResponse -> String
$cshow :: DescribeMatchmakingResponse -> String
showsPrec :: Int -> DescribeMatchmakingResponse -> ShowS
$cshowsPrec :: Int -> DescribeMatchmakingResponse -> ShowS
Prelude.Show, (forall x.
 DescribeMatchmakingResponse -> Rep DescribeMatchmakingResponse x)
-> (forall x.
    Rep DescribeMatchmakingResponse x -> DescribeMatchmakingResponse)
-> Generic DescribeMatchmakingResponse
forall x.
Rep DescribeMatchmakingResponse x -> DescribeMatchmakingResponse
forall x.
DescribeMatchmakingResponse -> Rep DescribeMatchmakingResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeMatchmakingResponse x -> DescribeMatchmakingResponse
$cfrom :: forall x.
DescribeMatchmakingResponse -> Rep DescribeMatchmakingResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMatchmakingResponse' 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:
--
-- 'ticketList', 'describeMatchmakingResponse_ticketList' - A collection of existing matchmaking ticket objects matching the
-- request.
--
-- 'httpStatus', 'describeMatchmakingResponse_httpStatus' - The response's http status code.
newDescribeMatchmakingResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeMatchmakingResponse
newDescribeMatchmakingResponse :: Int -> DescribeMatchmakingResponse
newDescribeMatchmakingResponse Int
pHttpStatus_ =
  DescribeMatchmakingResponse' :: Maybe [MatchmakingTicket] -> Int -> DescribeMatchmakingResponse
DescribeMatchmakingResponse'
    { $sel:ticketList:DescribeMatchmakingResponse' :: Maybe [MatchmakingTicket]
ticketList =
        Maybe [MatchmakingTicket]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeMatchmakingResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A collection of existing matchmaking ticket objects matching the
-- request.
describeMatchmakingResponse_ticketList :: Lens.Lens' DescribeMatchmakingResponse (Prelude.Maybe [MatchmakingTicket])
describeMatchmakingResponse_ticketList :: (Maybe [MatchmakingTicket] -> f (Maybe [MatchmakingTicket]))
-> DescribeMatchmakingResponse -> f DescribeMatchmakingResponse
describeMatchmakingResponse_ticketList = (DescribeMatchmakingResponse -> Maybe [MatchmakingTicket])
-> (DescribeMatchmakingResponse
    -> Maybe [MatchmakingTicket] -> DescribeMatchmakingResponse)
-> Lens
     DescribeMatchmakingResponse
     DescribeMatchmakingResponse
     (Maybe [MatchmakingTicket])
     (Maybe [MatchmakingTicket])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMatchmakingResponse' {Maybe [MatchmakingTicket]
ticketList :: Maybe [MatchmakingTicket]
$sel:ticketList:DescribeMatchmakingResponse' :: DescribeMatchmakingResponse -> Maybe [MatchmakingTicket]
ticketList} -> Maybe [MatchmakingTicket]
ticketList) (\s :: DescribeMatchmakingResponse
s@DescribeMatchmakingResponse' {} Maybe [MatchmakingTicket]
a -> DescribeMatchmakingResponse
s {$sel:ticketList:DescribeMatchmakingResponse' :: Maybe [MatchmakingTicket]
ticketList = Maybe [MatchmakingTicket]
a} :: DescribeMatchmakingResponse) ((Maybe [MatchmakingTicket] -> f (Maybe [MatchmakingTicket]))
 -> DescribeMatchmakingResponse -> f DescribeMatchmakingResponse)
-> ((Maybe [MatchmakingTicket] -> f (Maybe [MatchmakingTicket]))
    -> Maybe [MatchmakingTicket] -> f (Maybe [MatchmakingTicket]))
-> (Maybe [MatchmakingTicket] -> f (Maybe [MatchmakingTicket]))
-> DescribeMatchmakingResponse
-> f DescribeMatchmakingResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MatchmakingTicket]
  [MatchmakingTicket]
  [MatchmakingTicket]
  [MatchmakingTicket]
-> Iso
     (Maybe [MatchmakingTicket])
     (Maybe [MatchmakingTicket])
     (Maybe [MatchmakingTicket])
     (Maybe [MatchmakingTicket])
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 AnIso
  [MatchmakingTicket]
  [MatchmakingTicket]
  [MatchmakingTicket]
  [MatchmakingTicket]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeMatchmakingResponse