{-# 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.Lambda.GetAlias
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns details about a Lambda function
-- <https://docs.aws.amazon.com/lambda/latest/dg/versioning-aliases.html alias>.
module Amazonka.Lambda.GetAlias
  ( -- * Creating a Request
    GetAlias (..),
    newGetAlias,

    -- * Request Lenses
    getAlias_functionName,
    getAlias_name,

    -- * Destructuring the Response
    AliasConfiguration (..),
    newAliasConfiguration,

    -- * Response Lenses
    aliasConfiguration_aliasArn,
    aliasConfiguration_description,
    aliasConfiguration_functionVersion,
    aliasConfiguration_name,
    aliasConfiguration_revisionId,
    aliasConfiguration_routingConfig,
  )
where

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

-- | /See:/ 'newGetAlias' smart constructor.
data GetAlias = GetAlias'
  { -- | The name of the Lambda function.
    --
    -- __Name formats__
    --
    -- -   __Function name__ - @MyFunction@.
    --
    -- -   __Function ARN__ -
    --     @arn:aws:lambda:us-west-2:123456789012:function:MyFunction@.
    --
    -- -   __Partial ARN__ - @123456789012:function:MyFunction@.
    --
    -- The length constraint applies only to the full ARN. If you specify only
    -- the function name, it is limited to 64 characters in length.
    GetAlias -> Text
functionName :: Prelude.Text,
    -- | The name of the alias.
    GetAlias -> Text
name :: Prelude.Text
  }
  deriving (GetAlias -> GetAlias -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAlias -> GetAlias -> Bool
$c/= :: GetAlias -> GetAlias -> Bool
== :: GetAlias -> GetAlias -> Bool
$c== :: GetAlias -> GetAlias -> Bool
Prelude.Eq, ReadPrec [GetAlias]
ReadPrec GetAlias
Int -> ReadS GetAlias
ReadS [GetAlias]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAlias]
$creadListPrec :: ReadPrec [GetAlias]
readPrec :: ReadPrec GetAlias
$creadPrec :: ReadPrec GetAlias
readList :: ReadS [GetAlias]
$creadList :: ReadS [GetAlias]
readsPrec :: Int -> ReadS GetAlias
$creadsPrec :: Int -> ReadS GetAlias
Prelude.Read, Int -> GetAlias -> ShowS
[GetAlias] -> ShowS
GetAlias -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAlias] -> ShowS
$cshowList :: [GetAlias] -> ShowS
show :: GetAlias -> String
$cshow :: GetAlias -> String
showsPrec :: Int -> GetAlias -> ShowS
$cshowsPrec :: Int -> GetAlias -> ShowS
Prelude.Show, forall x. Rep GetAlias x -> GetAlias
forall x. GetAlias -> Rep GetAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAlias x -> GetAlias
$cfrom :: forall x. GetAlias -> Rep GetAlias x
Prelude.Generic)

-- |
-- Create a value of 'GetAlias' 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:
--
-- 'functionName', 'getAlias_functionName' - The name of the Lambda function.
--
-- __Name formats__
--
-- -   __Function name__ - @MyFunction@.
--
-- -   __Function ARN__ -
--     @arn:aws:lambda:us-west-2:123456789012:function:MyFunction@.
--
-- -   __Partial ARN__ - @123456789012:function:MyFunction@.
--
-- The length constraint applies only to the full ARN. If you specify only
-- the function name, it is limited to 64 characters in length.
--
-- 'name', 'getAlias_name' - The name of the alias.
newGetAlias ::
  -- | 'functionName'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  GetAlias
newGetAlias :: Text -> Text -> GetAlias
newGetAlias Text
pFunctionName_ Text
pName_ =
  GetAlias'
    { $sel:functionName:GetAlias' :: Text
functionName = Text
pFunctionName_,
      $sel:name:GetAlias' :: Text
name = Text
pName_
    }

-- | The name of the Lambda function.
--
-- __Name formats__
--
-- -   __Function name__ - @MyFunction@.
--
-- -   __Function ARN__ -
--     @arn:aws:lambda:us-west-2:123456789012:function:MyFunction@.
--
-- -   __Partial ARN__ - @123456789012:function:MyFunction@.
--
-- The length constraint applies only to the full ARN. If you specify only
-- the function name, it is limited to 64 characters in length.
getAlias_functionName :: Lens.Lens' GetAlias Prelude.Text
getAlias_functionName :: Lens' GetAlias Text
getAlias_functionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAlias' {Text
functionName :: Text
$sel:functionName:GetAlias' :: GetAlias -> Text
functionName} -> Text
functionName) (\s :: GetAlias
s@GetAlias' {} Text
a -> GetAlias
s {$sel:functionName:GetAlias' :: Text
functionName = Text
a} :: GetAlias)

-- | The name of the alias.
getAlias_name :: Lens.Lens' GetAlias Prelude.Text
getAlias_name :: Lens' GetAlias Text
getAlias_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAlias' {Text
name :: Text
$sel:name:GetAlias' :: GetAlias -> Text
name} -> Text
name) (\s :: GetAlias
s@GetAlias' {} Text
a -> GetAlias
s {$sel:name:GetAlias' :: Text
name = Text
a} :: GetAlias)

instance Core.AWSRequest GetAlias where
  type AWSResponse GetAlias = AliasConfiguration
  request :: (Service -> Service) -> GetAlias -> Request GetAlias
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAlias)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable GetAlias where
  hashWithSalt :: Int -> GetAlias -> Int
hashWithSalt Int
_salt GetAlias' {Text
name :: Text
functionName :: Text
$sel:name:GetAlias' :: GetAlias -> Text
$sel:functionName:GetAlias' :: GetAlias -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
functionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData GetAlias where
  rnf :: GetAlias -> ()
rnf GetAlias' {Text
name :: Text
functionName :: Text
$sel:name:GetAlias' :: GetAlias -> Text
$sel:functionName:GetAlias' :: GetAlias -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
functionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders GetAlias where
  toHeaders :: GetAlias -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath GetAlias where
  toPath :: GetAlias -> ByteString
toPath GetAlias' {Text
name :: Text
functionName :: Text
$sel:name:GetAlias' :: GetAlias -> Text
$sel:functionName:GetAlias' :: GetAlias -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2015-03-31/functions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
functionName,
        ByteString
"/aliases/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
name
      ]

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