{-# 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.GetFunctionConfiguration
-- 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 the version-specific settings of a Lambda function or version.
-- The output includes only options that can vary between versions of a
-- function. To modify these settings, use UpdateFunctionConfiguration.
--
-- To get all of a function\'s details, including function-level settings,
-- use GetFunction.
module Amazonka.Lambda.GetFunctionConfiguration
  ( -- * Creating a Request
    GetFunctionConfiguration (..),
    newGetFunctionConfiguration,

    -- * Request Lenses
    getFunctionConfiguration_qualifier,
    getFunctionConfiguration_functionName,

    -- * Destructuring the Response
    FunctionConfiguration (..),
    newFunctionConfiguration,

    -- * Response Lenses
    functionConfiguration_memorySize,
    functionConfiguration_runtime,
    functionConfiguration_state,
    functionConfiguration_signingProfileVersionArn,
    functionConfiguration_lastUpdateStatus,
    functionConfiguration_functionArn,
    functionConfiguration_kmsKeyArn,
    functionConfiguration_packageType,
    functionConfiguration_fileSystemConfigs,
    functionConfiguration_environment,
    functionConfiguration_deadLetterConfig,
    functionConfiguration_architectures,
    functionConfiguration_signingJobArn,
    functionConfiguration_role,
    functionConfiguration_vpcConfig,
    functionConfiguration_version,
    functionConfiguration_functionName,
    functionConfiguration_layers,
    functionConfiguration_codeSize,
    functionConfiguration_handler,
    functionConfiguration_timeout,
    functionConfiguration_lastUpdateStatusReason,
    functionConfiguration_stateReason,
    functionConfiguration_lastModified,
    functionConfiguration_codeSha256,
    functionConfiguration_tracingConfig,
    functionConfiguration_stateReasonCode,
    functionConfiguration_imageConfigResponse,
    functionConfiguration_description,
    functionConfiguration_lastUpdateStatusReasonCode,
    functionConfiguration_revisionId,
    functionConfiguration_masterArn,
  )
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:/ 'newGetFunctionConfiguration' smart constructor.
data GetFunctionConfiguration = GetFunctionConfiguration'
  { -- | Specify a version or alias to get details about a published version of
    -- the function.
    GetFunctionConfiguration -> Maybe Text
qualifier :: Prelude.Maybe Prelude.Text,
    -- | The name of the Lambda function, version, or alias.
    --
    -- __Name formats__
    --
    -- -   __Function name__ - @my-function@ (name-only), @my-function:v1@
    --     (with alias).
    --
    -- -   __Function ARN__ -
    --     @arn:aws:lambda:us-west-2:123456789012:function:my-function@.
    --
    -- -   __Partial ARN__ - @123456789012:function:my-function@.
    --
    -- You can append a version number or alias to any of the formats. The
    -- length constraint applies only to the full ARN. If you specify only the
    -- function name, it is limited to 64 characters in length.
    GetFunctionConfiguration -> Text
functionName :: Prelude.Text
  }
  deriving (GetFunctionConfiguration -> GetFunctionConfiguration -> Bool
(GetFunctionConfiguration -> GetFunctionConfiguration -> Bool)
-> (GetFunctionConfiguration -> GetFunctionConfiguration -> Bool)
-> Eq GetFunctionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFunctionConfiguration -> GetFunctionConfiguration -> Bool
$c/= :: GetFunctionConfiguration -> GetFunctionConfiguration -> Bool
== :: GetFunctionConfiguration -> GetFunctionConfiguration -> Bool
$c== :: GetFunctionConfiguration -> GetFunctionConfiguration -> Bool
Prelude.Eq, ReadPrec [GetFunctionConfiguration]
ReadPrec GetFunctionConfiguration
Int -> ReadS GetFunctionConfiguration
ReadS [GetFunctionConfiguration]
(Int -> ReadS GetFunctionConfiguration)
-> ReadS [GetFunctionConfiguration]
-> ReadPrec GetFunctionConfiguration
-> ReadPrec [GetFunctionConfiguration]
-> Read GetFunctionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFunctionConfiguration]
$creadListPrec :: ReadPrec [GetFunctionConfiguration]
readPrec :: ReadPrec GetFunctionConfiguration
$creadPrec :: ReadPrec GetFunctionConfiguration
readList :: ReadS [GetFunctionConfiguration]
$creadList :: ReadS [GetFunctionConfiguration]
readsPrec :: Int -> ReadS GetFunctionConfiguration
$creadsPrec :: Int -> ReadS GetFunctionConfiguration
Prelude.Read, Int -> GetFunctionConfiguration -> ShowS
[GetFunctionConfiguration] -> ShowS
GetFunctionConfiguration -> String
(Int -> GetFunctionConfiguration -> ShowS)
-> (GetFunctionConfiguration -> String)
-> ([GetFunctionConfiguration] -> ShowS)
-> Show GetFunctionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFunctionConfiguration] -> ShowS
$cshowList :: [GetFunctionConfiguration] -> ShowS
show :: GetFunctionConfiguration -> String
$cshow :: GetFunctionConfiguration -> String
showsPrec :: Int -> GetFunctionConfiguration -> ShowS
$cshowsPrec :: Int -> GetFunctionConfiguration -> ShowS
Prelude.Show, (forall x.
 GetFunctionConfiguration -> Rep GetFunctionConfiguration x)
-> (forall x.
    Rep GetFunctionConfiguration x -> GetFunctionConfiguration)
-> Generic GetFunctionConfiguration
forall x.
Rep GetFunctionConfiguration x -> GetFunctionConfiguration
forall x.
GetFunctionConfiguration -> Rep GetFunctionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetFunctionConfiguration x -> GetFunctionConfiguration
$cfrom :: forall x.
GetFunctionConfiguration -> Rep GetFunctionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'GetFunctionConfiguration' 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:
--
-- 'qualifier', 'getFunctionConfiguration_qualifier' - Specify a version or alias to get details about a published version of
-- the function.
--
-- 'functionName', 'getFunctionConfiguration_functionName' - The name of the Lambda function, version, or alias.
--
-- __Name formats__
--
-- -   __Function name__ - @my-function@ (name-only), @my-function:v1@
--     (with alias).
--
-- -   __Function ARN__ -
--     @arn:aws:lambda:us-west-2:123456789012:function:my-function@.
--
-- -   __Partial ARN__ - @123456789012:function:my-function@.
--
-- You can append a version number or alias to any of the formats. The
-- length constraint applies only to the full ARN. If you specify only the
-- function name, it is limited to 64 characters in length.
newGetFunctionConfiguration ::
  -- | 'functionName'
  Prelude.Text ->
  GetFunctionConfiguration
newGetFunctionConfiguration :: Text -> GetFunctionConfiguration
newGetFunctionConfiguration Text
pFunctionName_ =
  GetFunctionConfiguration' :: Maybe Text -> Text -> GetFunctionConfiguration
GetFunctionConfiguration'
    { $sel:qualifier:GetFunctionConfiguration' :: Maybe Text
qualifier =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:functionName:GetFunctionConfiguration' :: Text
functionName = Text
pFunctionName_
    }

-- | Specify a version or alias to get details about a published version of
-- the function.
getFunctionConfiguration_qualifier :: Lens.Lens' GetFunctionConfiguration (Prelude.Maybe Prelude.Text)
getFunctionConfiguration_qualifier :: (Maybe Text -> f (Maybe Text))
-> GetFunctionConfiguration -> f GetFunctionConfiguration
getFunctionConfiguration_qualifier = (GetFunctionConfiguration -> Maybe Text)
-> (GetFunctionConfiguration
    -> Maybe Text -> GetFunctionConfiguration)
-> Lens
     GetFunctionConfiguration
     GetFunctionConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFunctionConfiguration' {Maybe Text
qualifier :: Maybe Text
$sel:qualifier:GetFunctionConfiguration' :: GetFunctionConfiguration -> Maybe Text
qualifier} -> Maybe Text
qualifier) (\s :: GetFunctionConfiguration
s@GetFunctionConfiguration' {} Maybe Text
a -> GetFunctionConfiguration
s {$sel:qualifier:GetFunctionConfiguration' :: Maybe Text
qualifier = Maybe Text
a} :: GetFunctionConfiguration)

-- | The name of the Lambda function, version, or alias.
--
-- __Name formats__
--
-- -   __Function name__ - @my-function@ (name-only), @my-function:v1@
--     (with alias).
--
-- -   __Function ARN__ -
--     @arn:aws:lambda:us-west-2:123456789012:function:my-function@.
--
-- -   __Partial ARN__ - @123456789012:function:my-function@.
--
-- You can append a version number or alias to any of the formats. The
-- length constraint applies only to the full ARN. If you specify only the
-- function name, it is limited to 64 characters in length.
getFunctionConfiguration_functionName :: Lens.Lens' GetFunctionConfiguration Prelude.Text
getFunctionConfiguration_functionName :: (Text -> f Text)
-> GetFunctionConfiguration -> f GetFunctionConfiguration
getFunctionConfiguration_functionName = (GetFunctionConfiguration -> Text)
-> (GetFunctionConfiguration -> Text -> GetFunctionConfiguration)
-> Lens GetFunctionConfiguration GetFunctionConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFunctionConfiguration' {Text
functionName :: Text
$sel:functionName:GetFunctionConfiguration' :: GetFunctionConfiguration -> Text
functionName} -> Text
functionName) (\s :: GetFunctionConfiguration
s@GetFunctionConfiguration' {} Text
a -> GetFunctionConfiguration
s {$sel:functionName:GetFunctionConfiguration' :: Text
functionName = Text
a} :: GetFunctionConfiguration)

instance Core.AWSRequest GetFunctionConfiguration where
  type
    AWSResponse GetFunctionConfiguration =
      FunctionConfiguration
  request :: GetFunctionConfiguration -> Request GetFunctionConfiguration
request = Service
-> GetFunctionConfiguration -> Request GetFunctionConfiguration
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetFunctionConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFunctionConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetFunctionConfiguration))
-> Logger
-> Service
-> Proxy GetFunctionConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFunctionConfiguration)))
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 FunctionConfiguration
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetFunctionConfiguration

instance Prelude.NFData GetFunctionConfiguration

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

instance Core.ToPath GetFunctionConfiguration where
  toPath :: GetFunctionConfiguration -> ByteString
toPath GetFunctionConfiguration' {Maybe Text
Text
functionName :: Text
qualifier :: Maybe Text
$sel:functionName:GetFunctionConfiguration' :: GetFunctionConfiguration -> Text
$sel:qualifier:GetFunctionConfiguration' :: GetFunctionConfiguration -> Maybe 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
"/configuration"
      ]

instance Core.ToQuery GetFunctionConfiguration where
  toQuery :: GetFunctionConfiguration -> QueryString
toQuery GetFunctionConfiguration' {Maybe Text
Text
functionName :: Text
qualifier :: Maybe Text
$sel:functionName:GetFunctionConfiguration' :: GetFunctionConfiguration -> Text
$sel:qualifier:GetFunctionConfiguration' :: GetFunctionConfiguration -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"Qualifier" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
qualifier]