{-# 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.DescribeAlias
-- 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 properties for an alias. This operation returns all alias
-- metadata and settings. To get an alias\'s target fleet ID only, use
-- @ResolveAlias@.
--
-- To get alias properties, specify the alias ID. If successful, the
-- requested alias record is returned.
--
-- __Related actions__
--
-- CreateAlias | ListAliases | DescribeAlias | UpdateAlias | DeleteAlias |
-- ResolveAlias |
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
module Amazonka.GameLift.DescribeAlias
  ( -- * Creating a Request
    DescribeAlias (..),
    newDescribeAlias,

    -- * Request Lenses
    describeAlias_aliasId,

    -- * Destructuring the Response
    DescribeAliasResponse (..),
    newDescribeAliasResponse,

    -- * Response Lenses
    describeAliasResponse_alias,
    describeAliasResponse_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:/ 'newDescribeAlias' smart constructor.
data DescribeAlias = DescribeAlias'
  { -- | The unique identifier for the fleet alias that you want to retrieve. You
    -- can use either the alias ID or ARN value.
    DescribeAlias -> Text
aliasId :: Prelude.Text
  }
  deriving (DescribeAlias -> DescribeAlias -> Bool
(DescribeAlias -> DescribeAlias -> Bool)
-> (DescribeAlias -> DescribeAlias -> Bool) -> Eq DescribeAlias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAlias -> DescribeAlias -> Bool
$c/= :: DescribeAlias -> DescribeAlias -> Bool
== :: DescribeAlias -> DescribeAlias -> Bool
$c== :: DescribeAlias -> DescribeAlias -> Bool
Prelude.Eq, ReadPrec [DescribeAlias]
ReadPrec DescribeAlias
Int -> ReadS DescribeAlias
ReadS [DescribeAlias]
(Int -> ReadS DescribeAlias)
-> ReadS [DescribeAlias]
-> ReadPrec DescribeAlias
-> ReadPrec [DescribeAlias]
-> Read DescribeAlias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAlias]
$creadListPrec :: ReadPrec [DescribeAlias]
readPrec :: ReadPrec DescribeAlias
$creadPrec :: ReadPrec DescribeAlias
readList :: ReadS [DescribeAlias]
$creadList :: ReadS [DescribeAlias]
readsPrec :: Int -> ReadS DescribeAlias
$creadsPrec :: Int -> ReadS DescribeAlias
Prelude.Read, Int -> DescribeAlias -> ShowS
[DescribeAlias] -> ShowS
DescribeAlias -> String
(Int -> DescribeAlias -> ShowS)
-> (DescribeAlias -> String)
-> ([DescribeAlias] -> ShowS)
-> Show DescribeAlias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAlias] -> ShowS
$cshowList :: [DescribeAlias] -> ShowS
show :: DescribeAlias -> String
$cshow :: DescribeAlias -> String
showsPrec :: Int -> DescribeAlias -> ShowS
$cshowsPrec :: Int -> DescribeAlias -> ShowS
Prelude.Show, (forall x. DescribeAlias -> Rep DescribeAlias x)
-> (forall x. Rep DescribeAlias x -> DescribeAlias)
-> Generic DescribeAlias
forall x. Rep DescribeAlias x -> DescribeAlias
forall x. DescribeAlias -> Rep DescribeAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAlias x -> DescribeAlias
$cfrom :: forall x. DescribeAlias -> Rep DescribeAlias x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAlias' 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:
--
-- 'aliasId', 'describeAlias_aliasId' - The unique identifier for the fleet alias that you want to retrieve. You
-- can use either the alias ID or ARN value.
newDescribeAlias ::
  -- | 'aliasId'
  Prelude.Text ->
  DescribeAlias
newDescribeAlias :: Text -> DescribeAlias
newDescribeAlias Text
pAliasId_ =
  DescribeAlias' :: Text -> DescribeAlias
DescribeAlias' {$sel:aliasId:DescribeAlias' :: Text
aliasId = Text
pAliasId_}

-- | The unique identifier for the fleet alias that you want to retrieve. You
-- can use either the alias ID or ARN value.
describeAlias_aliasId :: Lens.Lens' DescribeAlias Prelude.Text
describeAlias_aliasId :: (Text -> f Text) -> DescribeAlias -> f DescribeAlias
describeAlias_aliasId = (DescribeAlias -> Text)
-> (DescribeAlias -> Text -> DescribeAlias)
-> Lens DescribeAlias DescribeAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlias' {Text
aliasId :: Text
$sel:aliasId:DescribeAlias' :: DescribeAlias -> Text
aliasId} -> Text
aliasId) (\s :: DescribeAlias
s@DescribeAlias' {} Text
a -> DescribeAlias
s {$sel:aliasId:DescribeAlias' :: Text
aliasId = Text
a} :: DescribeAlias)

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

instance Prelude.NFData DescribeAlias

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

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

instance Core.ToQuery DescribeAlias where
  toQuery :: DescribeAlias -> QueryString
toQuery = QueryString -> DescribeAlias -> 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:/ 'newDescribeAliasResponse' smart constructor.
data DescribeAliasResponse = DescribeAliasResponse'
  { -- | The requested alias resource.
    DescribeAliasResponse -> Maybe Alias
alias :: Prelude.Maybe Alias,
    -- | The response's http status code.
    DescribeAliasResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAliasResponse -> DescribeAliasResponse -> Bool
(DescribeAliasResponse -> DescribeAliasResponse -> Bool)
-> (DescribeAliasResponse -> DescribeAliasResponse -> Bool)
-> Eq DescribeAliasResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAliasResponse -> DescribeAliasResponse -> Bool
$c/= :: DescribeAliasResponse -> DescribeAliasResponse -> Bool
== :: DescribeAliasResponse -> DescribeAliasResponse -> Bool
$c== :: DescribeAliasResponse -> DescribeAliasResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAliasResponse]
ReadPrec DescribeAliasResponse
Int -> ReadS DescribeAliasResponse
ReadS [DescribeAliasResponse]
(Int -> ReadS DescribeAliasResponse)
-> ReadS [DescribeAliasResponse]
-> ReadPrec DescribeAliasResponse
-> ReadPrec [DescribeAliasResponse]
-> Read DescribeAliasResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAliasResponse]
$creadListPrec :: ReadPrec [DescribeAliasResponse]
readPrec :: ReadPrec DescribeAliasResponse
$creadPrec :: ReadPrec DescribeAliasResponse
readList :: ReadS [DescribeAliasResponse]
$creadList :: ReadS [DescribeAliasResponse]
readsPrec :: Int -> ReadS DescribeAliasResponse
$creadsPrec :: Int -> ReadS DescribeAliasResponse
Prelude.Read, Int -> DescribeAliasResponse -> ShowS
[DescribeAliasResponse] -> ShowS
DescribeAliasResponse -> String
(Int -> DescribeAliasResponse -> ShowS)
-> (DescribeAliasResponse -> String)
-> ([DescribeAliasResponse] -> ShowS)
-> Show DescribeAliasResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAliasResponse] -> ShowS
$cshowList :: [DescribeAliasResponse] -> ShowS
show :: DescribeAliasResponse -> String
$cshow :: DescribeAliasResponse -> String
showsPrec :: Int -> DescribeAliasResponse -> ShowS
$cshowsPrec :: Int -> DescribeAliasResponse -> ShowS
Prelude.Show, (forall x. DescribeAliasResponse -> Rep DescribeAliasResponse x)
-> (forall x. Rep DescribeAliasResponse x -> DescribeAliasResponse)
-> Generic DescribeAliasResponse
forall x. Rep DescribeAliasResponse x -> DescribeAliasResponse
forall x. DescribeAliasResponse -> Rep DescribeAliasResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAliasResponse x -> DescribeAliasResponse
$cfrom :: forall x. DescribeAliasResponse -> Rep DescribeAliasResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAliasResponse' 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:
--
-- 'alias', 'describeAliasResponse_alias' - The requested alias resource.
--
-- 'httpStatus', 'describeAliasResponse_httpStatus' - The response's http status code.
newDescribeAliasResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAliasResponse
newDescribeAliasResponse :: Int -> DescribeAliasResponse
newDescribeAliasResponse Int
pHttpStatus_ =
  DescribeAliasResponse' :: Maybe Alias -> Int -> DescribeAliasResponse
DescribeAliasResponse'
    { $sel:alias:DescribeAliasResponse' :: Maybe Alias
alias = Maybe Alias
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAliasResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The requested alias resource.
describeAliasResponse_alias :: Lens.Lens' DescribeAliasResponse (Prelude.Maybe Alias)
describeAliasResponse_alias :: (Maybe Alias -> f (Maybe Alias))
-> DescribeAliasResponse -> f DescribeAliasResponse
describeAliasResponse_alias = (DescribeAliasResponse -> Maybe Alias)
-> (DescribeAliasResponse -> Maybe Alias -> DescribeAliasResponse)
-> Lens
     DescribeAliasResponse
     DescribeAliasResponse
     (Maybe Alias)
     (Maybe Alias)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAliasResponse' {Maybe Alias
alias :: Maybe Alias
$sel:alias:DescribeAliasResponse' :: DescribeAliasResponse -> Maybe Alias
alias} -> Maybe Alias
alias) (\s :: DescribeAliasResponse
s@DescribeAliasResponse' {} Maybe Alias
a -> DescribeAliasResponse
s {$sel:alias:DescribeAliasResponse' :: Maybe Alias
alias = Maybe Alias
a} :: DescribeAliasResponse)

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

instance Prelude.NFData DescribeAliasResponse