{-# 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.ResolveAlias
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the fleet ID that an alias is currently pointing to.
--
-- __Related actions__
--
-- <https://docs.aws.amazon.com/gamelift/latest/developerguide/reference-awssdk.html#reference-awssdk-resources-fleets All APIs by task>
module Amazonka.GameLift.ResolveAlias
  ( -- * Creating a Request
    ResolveAlias (..),
    newResolveAlias,

    -- * Request Lenses
    resolveAlias_aliasId,

    -- * Destructuring the Response
    ResolveAliasResponse (..),
    newResolveAliasResponse,

    -- * Response Lenses
    resolveAliasResponse_fleetArn,
    resolveAliasResponse_fleetId,
    resolveAliasResponse_httpStatus,
  )
where

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

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

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

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

instance Core.AWSRequest ResolveAlias where
  type AWSResponse ResolveAlias = ResolveAliasResponse
  request :: (Service -> Service) -> ResolveAlias -> Request ResolveAlias
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ResolveAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ResolveAlias)))
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 Text -> Maybe Text -> Int -> ResolveAliasResponse
ResolveAliasResponse'
            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
"FleetArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"FleetId")
            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 ResolveAlias where
  hashWithSalt :: Int -> ResolveAlias -> Int
hashWithSalt Int
_salt ResolveAlias' {Text
aliasId :: Text
$sel:aliasId:ResolveAlias' :: ResolveAlias -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
aliasId

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

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

instance Data.ToJSON ResolveAlias where
  toJSON :: ResolveAlias -> Value
toJSON ResolveAlias' {Text
aliasId :: Text
$sel:aliasId:ResolveAlias' :: ResolveAlias -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"AliasId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
aliasId)]
      )

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

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

-- | /See:/ 'newResolveAliasResponse' smart constructor.
data ResolveAliasResponse = ResolveAliasResponse'
  { -- | The Amazon Resource Name
    -- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
    -- associated with the GameLift fleet resource that this alias points to.
    ResolveAliasResponse -> Maybe Text
fleetArn :: Prelude.Maybe Prelude.Text,
    -- | The fleet identifier that the alias is pointing to.
    ResolveAliasResponse -> Maybe Text
fleetId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ResolveAliasResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ResolveAliasResponse -> ResolveAliasResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResolveAliasResponse -> ResolveAliasResponse -> Bool
$c/= :: ResolveAliasResponse -> ResolveAliasResponse -> Bool
== :: ResolveAliasResponse -> ResolveAliasResponse -> Bool
$c== :: ResolveAliasResponse -> ResolveAliasResponse -> Bool
Prelude.Eq, ReadPrec [ResolveAliasResponse]
ReadPrec ResolveAliasResponse
Int -> ReadS ResolveAliasResponse
ReadS [ResolveAliasResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResolveAliasResponse]
$creadListPrec :: ReadPrec [ResolveAliasResponse]
readPrec :: ReadPrec ResolveAliasResponse
$creadPrec :: ReadPrec ResolveAliasResponse
readList :: ReadS [ResolveAliasResponse]
$creadList :: ReadS [ResolveAliasResponse]
readsPrec :: Int -> ReadS ResolveAliasResponse
$creadsPrec :: Int -> ReadS ResolveAliasResponse
Prelude.Read, Int -> ResolveAliasResponse -> ShowS
[ResolveAliasResponse] -> ShowS
ResolveAliasResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResolveAliasResponse] -> ShowS
$cshowList :: [ResolveAliasResponse] -> ShowS
show :: ResolveAliasResponse -> String
$cshow :: ResolveAliasResponse -> String
showsPrec :: Int -> ResolveAliasResponse -> ShowS
$cshowsPrec :: Int -> ResolveAliasResponse -> ShowS
Prelude.Show, forall x. Rep ResolveAliasResponse x -> ResolveAliasResponse
forall x. ResolveAliasResponse -> Rep ResolveAliasResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResolveAliasResponse x -> ResolveAliasResponse
$cfrom :: forall x. ResolveAliasResponse -> Rep ResolveAliasResponse x
Prelude.Generic)

-- |
-- Create a value of 'ResolveAliasResponse' 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:
--
-- 'fleetArn', 'resolveAliasResponse_fleetArn' - The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- associated with the GameLift fleet resource that this alias points to.
--
-- 'fleetId', 'resolveAliasResponse_fleetId' - The fleet identifier that the alias is pointing to.
--
-- 'httpStatus', 'resolveAliasResponse_httpStatus' - The response's http status code.
newResolveAliasResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ResolveAliasResponse
newResolveAliasResponse :: Int -> ResolveAliasResponse
newResolveAliasResponse Int
pHttpStatus_ =
  ResolveAliasResponse'
    { $sel:fleetArn:ResolveAliasResponse' :: Maybe Text
fleetArn = forall a. Maybe a
Prelude.Nothing,
      $sel:fleetId:ResolveAliasResponse' :: Maybe Text
fleetId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ResolveAliasResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- associated with the GameLift fleet resource that this alias points to.
resolveAliasResponse_fleetArn :: Lens.Lens' ResolveAliasResponse (Prelude.Maybe Prelude.Text)
resolveAliasResponse_fleetArn :: Lens' ResolveAliasResponse (Maybe Text)
resolveAliasResponse_fleetArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResolveAliasResponse' {Maybe Text
fleetArn :: Maybe Text
$sel:fleetArn:ResolveAliasResponse' :: ResolveAliasResponse -> Maybe Text
fleetArn} -> Maybe Text
fleetArn) (\s :: ResolveAliasResponse
s@ResolveAliasResponse' {} Maybe Text
a -> ResolveAliasResponse
s {$sel:fleetArn:ResolveAliasResponse' :: Maybe Text
fleetArn = Maybe Text
a} :: ResolveAliasResponse)

-- | The fleet identifier that the alias is pointing to.
resolveAliasResponse_fleetId :: Lens.Lens' ResolveAliasResponse (Prelude.Maybe Prelude.Text)
resolveAliasResponse_fleetId :: Lens' ResolveAliasResponse (Maybe Text)
resolveAliasResponse_fleetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResolveAliasResponse' {Maybe Text
fleetId :: Maybe Text
$sel:fleetId:ResolveAliasResponse' :: ResolveAliasResponse -> Maybe Text
fleetId} -> Maybe Text
fleetId) (\s :: ResolveAliasResponse
s@ResolveAliasResponse' {} Maybe Text
a -> ResolveAliasResponse
s {$sel:fleetId:ResolveAliasResponse' :: Maybe Text
fleetId = Maybe Text
a} :: ResolveAliasResponse)

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

instance Prelude.NFData ResolveAliasResponse where
  rnf :: ResolveAliasResponse -> ()
rnf ResolveAliasResponse' {Int
Maybe Text
httpStatus :: Int
fleetId :: Maybe Text
fleetArn :: Maybe Text
$sel:httpStatus:ResolveAliasResponse' :: ResolveAliasResponse -> Int
$sel:fleetId:ResolveAliasResponse' :: ResolveAliasResponse -> Maybe Text
$sel:fleetArn:ResolveAliasResponse' :: ResolveAliasResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fleetArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fleetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus