{-# 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.GetFunctionEventInvokeConfig
-- 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 configuration for asynchronous invocation for a function,
-- version, or alias.
--
-- To configure options for asynchronous invocation, use
-- PutFunctionEventInvokeConfig.
module Amazonka.Lambda.GetFunctionEventInvokeConfig
  ( -- * Creating a Request
    GetFunctionEventInvokeConfig (..),
    newGetFunctionEventInvokeConfig,

    -- * Request Lenses
    getFunctionEventInvokeConfig_qualifier,
    getFunctionEventInvokeConfig_functionName,

    -- * Destructuring the Response
    FunctionEventInvokeConfig (..),
    newFunctionEventInvokeConfig,

    -- * Response Lenses
    functionEventInvokeConfig_functionArn,
    functionEventInvokeConfig_maximumEventAgeInSeconds,
    functionEventInvokeConfig_maximumRetryAttempts,
    functionEventInvokeConfig_lastModified,
    functionEventInvokeConfig_destinationConfig,
  )
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:/ 'newGetFunctionEventInvokeConfig' smart constructor.
data GetFunctionEventInvokeConfig = GetFunctionEventInvokeConfig'
  { -- | A version number or alias name.
    GetFunctionEventInvokeConfig -> 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.
    GetFunctionEventInvokeConfig -> Text
functionName :: Prelude.Text
  }
  deriving (GetFunctionEventInvokeConfig
-> GetFunctionEventInvokeConfig -> Bool
(GetFunctionEventInvokeConfig
 -> GetFunctionEventInvokeConfig -> Bool)
-> (GetFunctionEventInvokeConfig
    -> GetFunctionEventInvokeConfig -> Bool)
-> Eq GetFunctionEventInvokeConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFunctionEventInvokeConfig
-> GetFunctionEventInvokeConfig -> Bool
$c/= :: GetFunctionEventInvokeConfig
-> GetFunctionEventInvokeConfig -> Bool
== :: GetFunctionEventInvokeConfig
-> GetFunctionEventInvokeConfig -> Bool
$c== :: GetFunctionEventInvokeConfig
-> GetFunctionEventInvokeConfig -> Bool
Prelude.Eq, ReadPrec [GetFunctionEventInvokeConfig]
ReadPrec GetFunctionEventInvokeConfig
Int -> ReadS GetFunctionEventInvokeConfig
ReadS [GetFunctionEventInvokeConfig]
(Int -> ReadS GetFunctionEventInvokeConfig)
-> ReadS [GetFunctionEventInvokeConfig]
-> ReadPrec GetFunctionEventInvokeConfig
-> ReadPrec [GetFunctionEventInvokeConfig]
-> Read GetFunctionEventInvokeConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFunctionEventInvokeConfig]
$creadListPrec :: ReadPrec [GetFunctionEventInvokeConfig]
readPrec :: ReadPrec GetFunctionEventInvokeConfig
$creadPrec :: ReadPrec GetFunctionEventInvokeConfig
readList :: ReadS [GetFunctionEventInvokeConfig]
$creadList :: ReadS [GetFunctionEventInvokeConfig]
readsPrec :: Int -> ReadS GetFunctionEventInvokeConfig
$creadsPrec :: Int -> ReadS GetFunctionEventInvokeConfig
Prelude.Read, Int -> GetFunctionEventInvokeConfig -> ShowS
[GetFunctionEventInvokeConfig] -> ShowS
GetFunctionEventInvokeConfig -> String
(Int -> GetFunctionEventInvokeConfig -> ShowS)
-> (GetFunctionEventInvokeConfig -> String)
-> ([GetFunctionEventInvokeConfig] -> ShowS)
-> Show GetFunctionEventInvokeConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFunctionEventInvokeConfig] -> ShowS
$cshowList :: [GetFunctionEventInvokeConfig] -> ShowS
show :: GetFunctionEventInvokeConfig -> String
$cshow :: GetFunctionEventInvokeConfig -> String
showsPrec :: Int -> GetFunctionEventInvokeConfig -> ShowS
$cshowsPrec :: Int -> GetFunctionEventInvokeConfig -> ShowS
Prelude.Show, (forall x.
 GetFunctionEventInvokeConfig -> Rep GetFunctionEventInvokeConfig x)
-> (forall x.
    Rep GetFunctionEventInvokeConfig x -> GetFunctionEventInvokeConfig)
-> Generic GetFunctionEventInvokeConfig
forall x.
Rep GetFunctionEventInvokeConfig x -> GetFunctionEventInvokeConfig
forall x.
GetFunctionEventInvokeConfig -> Rep GetFunctionEventInvokeConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetFunctionEventInvokeConfig x -> GetFunctionEventInvokeConfig
$cfrom :: forall x.
GetFunctionEventInvokeConfig -> Rep GetFunctionEventInvokeConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetFunctionEventInvokeConfig' 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', 'getFunctionEventInvokeConfig_qualifier' - A version number or alias name.
--
-- 'functionName', 'getFunctionEventInvokeConfig_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.
newGetFunctionEventInvokeConfig ::
  -- | 'functionName'
  Prelude.Text ->
  GetFunctionEventInvokeConfig
newGetFunctionEventInvokeConfig :: Text -> GetFunctionEventInvokeConfig
newGetFunctionEventInvokeConfig Text
pFunctionName_ =
  GetFunctionEventInvokeConfig' :: Maybe Text -> Text -> GetFunctionEventInvokeConfig
GetFunctionEventInvokeConfig'
    { $sel:qualifier:GetFunctionEventInvokeConfig' :: Maybe Text
qualifier =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:functionName:GetFunctionEventInvokeConfig' :: Text
functionName = Text
pFunctionName_
    }

-- | A version number or alias name.
getFunctionEventInvokeConfig_qualifier :: Lens.Lens' GetFunctionEventInvokeConfig (Prelude.Maybe Prelude.Text)
getFunctionEventInvokeConfig_qualifier :: (Maybe Text -> f (Maybe Text))
-> GetFunctionEventInvokeConfig -> f GetFunctionEventInvokeConfig
getFunctionEventInvokeConfig_qualifier = (GetFunctionEventInvokeConfig -> Maybe Text)
-> (GetFunctionEventInvokeConfig
    -> Maybe Text -> GetFunctionEventInvokeConfig)
-> Lens
     GetFunctionEventInvokeConfig
     GetFunctionEventInvokeConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFunctionEventInvokeConfig' {Maybe Text
qualifier :: Maybe Text
$sel:qualifier:GetFunctionEventInvokeConfig' :: GetFunctionEventInvokeConfig -> Maybe Text
qualifier} -> Maybe Text
qualifier) (\s :: GetFunctionEventInvokeConfig
s@GetFunctionEventInvokeConfig' {} Maybe Text
a -> GetFunctionEventInvokeConfig
s {$sel:qualifier:GetFunctionEventInvokeConfig' :: Maybe Text
qualifier = Maybe Text
a} :: GetFunctionEventInvokeConfig)

-- | 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.
getFunctionEventInvokeConfig_functionName :: Lens.Lens' GetFunctionEventInvokeConfig Prelude.Text
getFunctionEventInvokeConfig_functionName :: (Text -> f Text)
-> GetFunctionEventInvokeConfig -> f GetFunctionEventInvokeConfig
getFunctionEventInvokeConfig_functionName = (GetFunctionEventInvokeConfig -> Text)
-> (GetFunctionEventInvokeConfig
    -> Text -> GetFunctionEventInvokeConfig)
-> Lens
     GetFunctionEventInvokeConfig GetFunctionEventInvokeConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFunctionEventInvokeConfig' {Text
functionName :: Text
$sel:functionName:GetFunctionEventInvokeConfig' :: GetFunctionEventInvokeConfig -> Text
functionName} -> Text
functionName) (\s :: GetFunctionEventInvokeConfig
s@GetFunctionEventInvokeConfig' {} Text
a -> GetFunctionEventInvokeConfig
s {$sel:functionName:GetFunctionEventInvokeConfig' :: Text
functionName = Text
a} :: GetFunctionEventInvokeConfig)

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

instance
  Prelude.Hashable
    GetFunctionEventInvokeConfig

instance Prelude.NFData GetFunctionEventInvokeConfig

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

instance Core.ToPath GetFunctionEventInvokeConfig where
  toPath :: GetFunctionEventInvokeConfig -> ByteString
toPath GetFunctionEventInvokeConfig' {Maybe Text
Text
functionName :: Text
qualifier :: Maybe Text
$sel:functionName:GetFunctionEventInvokeConfig' :: GetFunctionEventInvokeConfig -> Text
$sel:qualifier:GetFunctionEventInvokeConfig' :: GetFunctionEventInvokeConfig -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2019-09-25/functions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
functionName,
        ByteString
"/event-invoke-config"
      ]

instance Core.ToQuery GetFunctionEventInvokeConfig where
  toQuery :: GetFunctionEventInvokeConfig -> QueryString
toQuery GetFunctionEventInvokeConfig' {Maybe Text
Text
functionName :: Text
qualifier :: Maybe Text
$sel:functionName:GetFunctionEventInvokeConfig' :: GetFunctionEventInvokeConfig -> Text
$sel:qualifier:GetFunctionEventInvokeConfig' :: GetFunctionEventInvokeConfig -> 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]