{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_destinationConfig,
    functionEventInvokeConfig_functionArn,
    functionEventInvokeConfig_lastModified,
    functionEventInvokeConfig_maximumEventAgeInSeconds,
    functionEventInvokeConfig_maximumRetryAttempts,
  )
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:/ '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
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]
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
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.
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'
    { $sel:qualifier:GetFunctionEventInvokeConfig' :: Maybe Text
qualifier =
        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 :: Lens' GetFunctionEventInvokeConfig (Maybe Text)
getFunctionEventInvokeConfig_qualifier = 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 :: Lens' GetFunctionEventInvokeConfig Text
getFunctionEventInvokeConfig_functionName = 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 :: (Service -> Service)
-> GetFunctionEventInvokeConfig
-> Request GetFunctionEventInvokeConfig
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 GetFunctionEventInvokeConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFunctionEventInvokeConfig)))
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
    GetFunctionEventInvokeConfig
  where
  hashWithSalt :: Int -> GetFunctionEventInvokeConfig -> Int
hashWithSalt Int
_salt GetFunctionEventInvokeConfig' {Maybe Text
Text
functionName :: Text
qualifier :: Maybe Text
$sel:functionName:GetFunctionEventInvokeConfig' :: GetFunctionEventInvokeConfig -> Text
$sel:qualifier:GetFunctionEventInvokeConfig' :: GetFunctionEventInvokeConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
qualifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
functionName

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

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

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2019-09-25/functions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
functionName,
        ByteString
"/event-invoke-config"
      ]

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"Qualifier" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
qualifier]