{-# 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-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 the fleet ID that an alias is currently pointing to.
--
-- __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.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 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:/ '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
(ResolveAlias -> ResolveAlias -> Bool)
-> (ResolveAlias -> ResolveAlias -> Bool) -> Eq ResolveAlias
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]
(Int -> ReadS ResolveAlias)
-> ReadS [ResolveAlias]
-> ReadPrec ResolveAlias
-> ReadPrec [ResolveAlias]
-> Read 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
(Int -> ResolveAlias -> ShowS)
-> (ResolveAlias -> String)
-> ([ResolveAlias] -> ShowS)
-> Show ResolveAlias
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. ResolveAlias -> Rep ResolveAlias x)
-> (forall x. Rep ResolveAlias x -> ResolveAlias)
-> Generic ResolveAlias
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' :: Text -> ResolveAlias
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 :: (Text -> f Text) -> ResolveAlias -> f ResolveAlias
resolveAlias_aliasId = (ResolveAlias -> Text)
-> (ResolveAlias -> Text -> ResolveAlias)
-> Lens ResolveAlias ResolveAlias Text Text
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 :: ResolveAlias -> Request ResolveAlias
request = Service -> ResolveAlias -> Request ResolveAlias
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ResolveAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ResolveAlias)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ResolveAlias))
-> Logger
-> Service
-> Proxy ResolveAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ResolveAlias)))
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 Text -> Maybe Text -> Int -> ResolveAliasResponse
ResolveAliasResponse'
            (Maybe Text -> Maybe Text -> Int -> ResolveAliasResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> ResolveAliasResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FleetArn")
            Either String (Maybe Text -> Int -> ResolveAliasResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ResolveAliasResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FleetId")
            Either String (Int -> ResolveAliasResponse)
-> Either String Int -> Either String ResolveAliasResponse
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 ResolveAlias

instance Prelude.NFData ResolveAlias

instance Core.ToHeaders ResolveAlias where
  toHeaders :: ResolveAlias -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ResolveAlias -> 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.ResolveAlias" :: 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 ResolveAlias where
  toJSON :: ResolveAlias -> Value
toJSON ResolveAlias' {Text
aliasId :: Text
$sel:aliasId:ResolveAlias' :: ResolveAlias -> 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 ResolveAlias where
  toPath :: ResolveAlias -> ByteString
toPath = ByteString -> ResolveAlias -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ResolveAlias where
  toQuery :: ResolveAlias -> QueryString
toQuery = QueryString -> ResolveAlias -> 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:/ '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
(ResolveAliasResponse -> ResolveAliasResponse -> Bool)
-> (ResolveAliasResponse -> ResolveAliasResponse -> Bool)
-> Eq ResolveAliasResponse
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]
(Int -> ReadS ResolveAliasResponse)
-> ReadS [ResolveAliasResponse]
-> ReadPrec ResolveAliasResponse
-> ReadPrec [ResolveAliasResponse]
-> Read 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
(Int -> ResolveAliasResponse -> ShowS)
-> (ResolveAliasResponse -> String)
-> ([ResolveAliasResponse] -> ShowS)
-> Show ResolveAliasResponse
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. ResolveAliasResponse -> Rep ResolveAliasResponse x)
-> (forall x. Rep ResolveAliasResponse x -> ResolveAliasResponse)
-> Generic ResolveAliasResponse
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' :: Maybe Text -> Maybe Text -> Int -> ResolveAliasResponse
ResolveAliasResponse'
    { $sel:fleetArn:ResolveAliasResponse' :: Maybe Text
fleetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fleetId:ResolveAliasResponse' :: Maybe Text
fleetId = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> ResolveAliasResponse -> f ResolveAliasResponse
resolveAliasResponse_fleetArn = (ResolveAliasResponse -> Maybe Text)
-> (ResolveAliasResponse -> Maybe Text -> ResolveAliasResponse)
-> Lens
     ResolveAliasResponse ResolveAliasResponse (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> ResolveAliasResponse -> f ResolveAliasResponse
resolveAliasResponse_fleetId = (ResolveAliasResponse -> Maybe Text)
-> (ResolveAliasResponse -> Maybe Text -> ResolveAliasResponse)
-> Lens
     ResolveAliasResponse ResolveAliasResponse (Maybe Text) (Maybe Text)
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 :: (Int -> f Int) -> ResolveAliasResponse -> f ResolveAliasResponse
resolveAliasResponse_httpStatus = (ResolveAliasResponse -> Int)
-> (ResolveAliasResponse -> Int -> ResolveAliasResponse)
-> Lens ResolveAliasResponse ResolveAliasResponse Int Int
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