{-# 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.UpdateAlias
-- 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)
--
-- Updates properties for an alias. To update properties, specify the alias
-- ID to be updated and provide the information to be changed. To reassign
-- an alias to another fleet, provide an updated routing strategy. If
-- successful, the updated 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.UpdateAlias
  ( -- * Creating a Request
    UpdateAlias (..),
    newUpdateAlias,

    -- * Request Lenses
    updateAlias_routingStrategy,
    updateAlias_name,
    updateAlias_description,
    updateAlias_aliasId,

    -- * Destructuring the Response
    UpdateAliasResponse (..),
    newUpdateAliasResponse,

    -- * Response Lenses
    updateAliasResponse_alias,
    updateAliasResponse_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:/ 'newUpdateAlias' smart constructor.
data UpdateAlias = UpdateAlias'
  { -- | The routing configuration, including routing type and fleet target, for
    -- the alias.
    UpdateAlias -> Maybe RoutingStrategy
routingStrategy :: Prelude.Maybe RoutingStrategy,
    -- | A descriptive label that is associated with an alias. Alias names do not
    -- need to be unique.
    UpdateAlias -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A human-readable description of the alias.
    UpdateAlias -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the alias that you want to update. You can use
    -- either the alias ID or ARN value.
    UpdateAlias -> Text
aliasId :: Prelude.Text
  }
  deriving (UpdateAlias -> UpdateAlias -> Bool
(UpdateAlias -> UpdateAlias -> Bool)
-> (UpdateAlias -> UpdateAlias -> Bool) -> Eq UpdateAlias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAlias -> UpdateAlias -> Bool
$c/= :: UpdateAlias -> UpdateAlias -> Bool
== :: UpdateAlias -> UpdateAlias -> Bool
$c== :: UpdateAlias -> UpdateAlias -> Bool
Prelude.Eq, ReadPrec [UpdateAlias]
ReadPrec UpdateAlias
Int -> ReadS UpdateAlias
ReadS [UpdateAlias]
(Int -> ReadS UpdateAlias)
-> ReadS [UpdateAlias]
-> ReadPrec UpdateAlias
-> ReadPrec [UpdateAlias]
-> Read UpdateAlias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAlias]
$creadListPrec :: ReadPrec [UpdateAlias]
readPrec :: ReadPrec UpdateAlias
$creadPrec :: ReadPrec UpdateAlias
readList :: ReadS [UpdateAlias]
$creadList :: ReadS [UpdateAlias]
readsPrec :: Int -> ReadS UpdateAlias
$creadsPrec :: Int -> ReadS UpdateAlias
Prelude.Read, Int -> UpdateAlias -> ShowS
[UpdateAlias] -> ShowS
UpdateAlias -> String
(Int -> UpdateAlias -> ShowS)
-> (UpdateAlias -> String)
-> ([UpdateAlias] -> ShowS)
-> Show UpdateAlias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAlias] -> ShowS
$cshowList :: [UpdateAlias] -> ShowS
show :: UpdateAlias -> String
$cshow :: UpdateAlias -> String
showsPrec :: Int -> UpdateAlias -> ShowS
$cshowsPrec :: Int -> UpdateAlias -> ShowS
Prelude.Show, (forall x. UpdateAlias -> Rep UpdateAlias x)
-> (forall x. Rep UpdateAlias x -> UpdateAlias)
-> Generic UpdateAlias
forall x. Rep UpdateAlias x -> UpdateAlias
forall x. UpdateAlias -> Rep UpdateAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAlias x -> UpdateAlias
$cfrom :: forall x. UpdateAlias -> Rep UpdateAlias x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAlias' 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:
--
-- 'routingStrategy', 'updateAlias_routingStrategy' - The routing configuration, including routing type and fleet target, for
-- the alias.
--
-- 'name', 'updateAlias_name' - A descriptive label that is associated with an alias. Alias names do not
-- need to be unique.
--
-- 'description', 'updateAlias_description' - A human-readable description of the alias.
--
-- 'aliasId', 'updateAlias_aliasId' - A unique identifier for the alias that you want to update. You can use
-- either the alias ID or ARN value.
newUpdateAlias ::
  -- | 'aliasId'
  Prelude.Text ->
  UpdateAlias
newUpdateAlias :: Text -> UpdateAlias
newUpdateAlias Text
pAliasId_ =
  UpdateAlias' :: Maybe RoutingStrategy
-> Maybe Text -> Maybe Text -> Text -> UpdateAlias
UpdateAlias'
    { $sel:routingStrategy:UpdateAlias' :: Maybe RoutingStrategy
routingStrategy = Maybe RoutingStrategy
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateAlias' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateAlias' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:aliasId:UpdateAlias' :: Text
aliasId = Text
pAliasId_
    }

-- | The routing configuration, including routing type and fleet target, for
-- the alias.
updateAlias_routingStrategy :: Lens.Lens' UpdateAlias (Prelude.Maybe RoutingStrategy)
updateAlias_routingStrategy :: (Maybe RoutingStrategy -> f (Maybe RoutingStrategy))
-> UpdateAlias -> f UpdateAlias
updateAlias_routingStrategy = (UpdateAlias -> Maybe RoutingStrategy)
-> (UpdateAlias -> Maybe RoutingStrategy -> UpdateAlias)
-> Lens
     UpdateAlias
     UpdateAlias
     (Maybe RoutingStrategy)
     (Maybe RoutingStrategy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAlias' {Maybe RoutingStrategy
routingStrategy :: Maybe RoutingStrategy
$sel:routingStrategy:UpdateAlias' :: UpdateAlias -> Maybe RoutingStrategy
routingStrategy} -> Maybe RoutingStrategy
routingStrategy) (\s :: UpdateAlias
s@UpdateAlias' {} Maybe RoutingStrategy
a -> UpdateAlias
s {$sel:routingStrategy:UpdateAlias' :: Maybe RoutingStrategy
routingStrategy = Maybe RoutingStrategy
a} :: UpdateAlias)

-- | A descriptive label that is associated with an alias. Alias names do not
-- need to be unique.
updateAlias_name :: Lens.Lens' UpdateAlias (Prelude.Maybe Prelude.Text)
updateAlias_name :: (Maybe Text -> f (Maybe Text)) -> UpdateAlias -> f UpdateAlias
updateAlias_name = (UpdateAlias -> Maybe Text)
-> (UpdateAlias -> Maybe Text -> UpdateAlias)
-> Lens UpdateAlias UpdateAlias (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAlias' {Maybe Text
name :: Maybe Text
$sel:name:UpdateAlias' :: UpdateAlias -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateAlias
s@UpdateAlias' {} Maybe Text
a -> UpdateAlias
s {$sel:name:UpdateAlias' :: Maybe Text
name = Maybe Text
a} :: UpdateAlias)

-- | A human-readable description of the alias.
updateAlias_description :: Lens.Lens' UpdateAlias (Prelude.Maybe Prelude.Text)
updateAlias_description :: (Maybe Text -> f (Maybe Text)) -> UpdateAlias -> f UpdateAlias
updateAlias_description = (UpdateAlias -> Maybe Text)
-> (UpdateAlias -> Maybe Text -> UpdateAlias)
-> Lens UpdateAlias UpdateAlias (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAlias' {Maybe Text
description :: Maybe Text
$sel:description:UpdateAlias' :: UpdateAlias -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateAlias
s@UpdateAlias' {} Maybe Text
a -> UpdateAlias
s {$sel:description:UpdateAlias' :: Maybe Text
description = Maybe Text
a} :: UpdateAlias)

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

instance Core.AWSRequest UpdateAlias where
  type AWSResponse UpdateAlias = UpdateAliasResponse
  request :: UpdateAlias -> Request UpdateAlias
request = Service -> UpdateAlias -> Request UpdateAlias
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAlias)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateAlias))
-> Logger
-> Service
-> Proxy UpdateAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAlias)))
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 -> UpdateAliasResponse
UpdateAliasResponse'
            (Maybe Alias -> Int -> UpdateAliasResponse)
-> Either String (Maybe Alias)
-> Either String (Int -> UpdateAliasResponse)
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 -> UpdateAliasResponse)
-> Either String Int -> Either String UpdateAliasResponse
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 UpdateAlias

instance Prelude.NFData UpdateAlias

instance Core.ToHeaders UpdateAlias where
  toHeaders :: UpdateAlias -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateAlias -> 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.UpdateAlias" :: 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 UpdateAlias where
  toJSON :: UpdateAlias -> Value
toJSON UpdateAlias' {Maybe Text
Maybe RoutingStrategy
Text
aliasId :: Text
description :: Maybe Text
name :: Maybe Text
routingStrategy :: Maybe RoutingStrategy
$sel:aliasId:UpdateAlias' :: UpdateAlias -> Text
$sel:description:UpdateAlias' :: UpdateAlias -> Maybe Text
$sel:name:UpdateAlias' :: UpdateAlias -> Maybe Text
$sel:routingStrategy:UpdateAlias' :: UpdateAlias -> Maybe RoutingStrategy
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RoutingStrategy" Text -> RoutingStrategy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RoutingStrategy -> Pair) -> Maybe RoutingStrategy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RoutingStrategy
routingStrategy,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            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 UpdateAlias where
  toPath :: UpdateAlias -> ByteString
toPath = ByteString -> UpdateAlias -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- |
-- Create a value of 'UpdateAliasResponse' 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', 'updateAliasResponse_alias' - The updated alias resource.
--
-- 'httpStatus', 'updateAliasResponse_httpStatus' - The response's http status code.
newUpdateAliasResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateAliasResponse
newUpdateAliasResponse :: Int -> UpdateAliasResponse
newUpdateAliasResponse Int
pHttpStatus_ =
  UpdateAliasResponse' :: Maybe Alias -> Int -> UpdateAliasResponse
UpdateAliasResponse'
    { $sel:alias:UpdateAliasResponse' :: Maybe Alias
alias = Maybe Alias
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateAliasResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance Prelude.NFData UpdateAliasResponse