{-# 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-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)
--
-- 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_routingConfig,
    aliasConfiguration_name,
    aliasConfiguration_functionVersion,
    aliasConfiguration_aliasArn,
    aliasConfiguration_description,
    aliasConfiguration_revisionId,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Lambda.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

-- | /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
(GetAlias -> GetAlias -> Bool)
-> (GetAlias -> GetAlias -> Bool) -> Eq GetAlias
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]
(Int -> ReadS GetAlias)
-> ReadS [GetAlias]
-> ReadPrec GetAlias
-> ReadPrec [GetAlias]
-> Read 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
(Int -> GetAlias -> ShowS)
-> (GetAlias -> String) -> ([GetAlias] -> ShowS) -> Show GetAlias
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. GetAlias -> Rep GetAlias x)
-> (forall x. Rep GetAlias x -> GetAlias) -> Generic GetAlias
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' :: Text -> Text -> GetAlias
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 :: (Text -> f Text) -> GetAlias -> f GetAlias
getAlias_functionName = (GetAlias -> Text)
-> (GetAlias -> Text -> GetAlias)
-> Lens GetAlias GetAlias Text Text
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 :: (Text -> f Text) -> GetAlias -> f GetAlias
getAlias_name = (GetAlias -> Text)
-> (GetAlias -> Text -> GetAlias)
-> Lens GetAlias GetAlias Text Text
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 :: GetAlias -> Request GetAlias
request = Service -> GetAlias -> Request GetAlias
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAlias)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetAlias))
-> Logger
-> Service
-> Proxy GetAlias
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAlias)))
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 -> Object -> Either String AliasConfiguration
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetAlias

instance Prelude.NFData GetAlias

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

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

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