{-# 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.GetEventSourceMapping
-- 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 an event source mapping. You can get the
-- identifier of a mapping from the output of ListEventSourceMappings.
module Amazonka.Lambda.GetEventSourceMapping
  ( -- * Creating a Request
    GetEventSourceMapping (..),
    newGetEventSourceMapping,

    -- * Request Lenses
    getEventSourceMapping_uuid,

    -- * Destructuring the Response
    EventSourceMappingConfiguration (..),
    newEventSourceMappingConfiguration,

    -- * Response Lenses
    eventSourceMappingConfiguration_eventSourceArn,
    eventSourceMappingConfiguration_state,
    eventSourceMappingConfiguration_startingPositionTimestamp,
    eventSourceMappingConfiguration_functionArn,
    eventSourceMappingConfiguration_topics,
    eventSourceMappingConfiguration_queues,
    eventSourceMappingConfiguration_bisectBatchOnFunctionError,
    eventSourceMappingConfiguration_uuid,
    eventSourceMappingConfiguration_parallelizationFactor,
    eventSourceMappingConfiguration_lastProcessingResult,
    eventSourceMappingConfiguration_maximumRetryAttempts,
    eventSourceMappingConfiguration_batchSize,
    eventSourceMappingConfiguration_stateTransitionReason,
    eventSourceMappingConfiguration_maximumBatchingWindowInSeconds,
    eventSourceMappingConfiguration_sourceAccessConfigurations,
    eventSourceMappingConfiguration_maximumRecordAgeInSeconds,
    eventSourceMappingConfiguration_functionResponseTypes,
    eventSourceMappingConfiguration_tumblingWindowInSeconds,
    eventSourceMappingConfiguration_selfManagedEventSource,
    eventSourceMappingConfiguration_lastModified,
    eventSourceMappingConfiguration_destinationConfig,
    eventSourceMappingConfiguration_startingPosition,
  )
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:/ 'newGetEventSourceMapping' smart constructor.
data GetEventSourceMapping = GetEventSourceMapping'
  { -- | The identifier of the event source mapping.
    GetEventSourceMapping -> Text
uuid :: Prelude.Text
  }
  deriving (GetEventSourceMapping -> GetEventSourceMapping -> Bool
(GetEventSourceMapping -> GetEventSourceMapping -> Bool)
-> (GetEventSourceMapping -> GetEventSourceMapping -> Bool)
-> Eq GetEventSourceMapping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEventSourceMapping -> GetEventSourceMapping -> Bool
$c/= :: GetEventSourceMapping -> GetEventSourceMapping -> Bool
== :: GetEventSourceMapping -> GetEventSourceMapping -> Bool
$c== :: GetEventSourceMapping -> GetEventSourceMapping -> Bool
Prelude.Eq, ReadPrec [GetEventSourceMapping]
ReadPrec GetEventSourceMapping
Int -> ReadS GetEventSourceMapping
ReadS [GetEventSourceMapping]
(Int -> ReadS GetEventSourceMapping)
-> ReadS [GetEventSourceMapping]
-> ReadPrec GetEventSourceMapping
-> ReadPrec [GetEventSourceMapping]
-> Read GetEventSourceMapping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEventSourceMapping]
$creadListPrec :: ReadPrec [GetEventSourceMapping]
readPrec :: ReadPrec GetEventSourceMapping
$creadPrec :: ReadPrec GetEventSourceMapping
readList :: ReadS [GetEventSourceMapping]
$creadList :: ReadS [GetEventSourceMapping]
readsPrec :: Int -> ReadS GetEventSourceMapping
$creadsPrec :: Int -> ReadS GetEventSourceMapping
Prelude.Read, Int -> GetEventSourceMapping -> ShowS
[GetEventSourceMapping] -> ShowS
GetEventSourceMapping -> String
(Int -> GetEventSourceMapping -> ShowS)
-> (GetEventSourceMapping -> String)
-> ([GetEventSourceMapping] -> ShowS)
-> Show GetEventSourceMapping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEventSourceMapping] -> ShowS
$cshowList :: [GetEventSourceMapping] -> ShowS
show :: GetEventSourceMapping -> String
$cshow :: GetEventSourceMapping -> String
showsPrec :: Int -> GetEventSourceMapping -> ShowS
$cshowsPrec :: Int -> GetEventSourceMapping -> ShowS
Prelude.Show, (forall x. GetEventSourceMapping -> Rep GetEventSourceMapping x)
-> (forall x. Rep GetEventSourceMapping x -> GetEventSourceMapping)
-> Generic GetEventSourceMapping
forall x. Rep GetEventSourceMapping x -> GetEventSourceMapping
forall x. GetEventSourceMapping -> Rep GetEventSourceMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEventSourceMapping x -> GetEventSourceMapping
$cfrom :: forall x. GetEventSourceMapping -> Rep GetEventSourceMapping x
Prelude.Generic)

-- |
-- Create a value of 'GetEventSourceMapping' 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:
--
-- 'uuid', 'getEventSourceMapping_uuid' - The identifier of the event source mapping.
newGetEventSourceMapping ::
  -- | 'uuid'
  Prelude.Text ->
  GetEventSourceMapping
newGetEventSourceMapping :: Text -> GetEventSourceMapping
newGetEventSourceMapping Text
pUUID_ =
  GetEventSourceMapping' :: Text -> GetEventSourceMapping
GetEventSourceMapping' {$sel:uuid:GetEventSourceMapping' :: Text
uuid = Text
pUUID_}

-- | The identifier of the event source mapping.
getEventSourceMapping_uuid :: Lens.Lens' GetEventSourceMapping Prelude.Text
getEventSourceMapping_uuid :: (Text -> f Text)
-> GetEventSourceMapping -> f GetEventSourceMapping
getEventSourceMapping_uuid = (GetEventSourceMapping -> Text)
-> (GetEventSourceMapping -> Text -> GetEventSourceMapping)
-> Lens GetEventSourceMapping GetEventSourceMapping Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventSourceMapping' {Text
uuid :: Text
$sel:uuid:GetEventSourceMapping' :: GetEventSourceMapping -> Text
uuid} -> Text
uuid) (\s :: GetEventSourceMapping
s@GetEventSourceMapping' {} Text
a -> GetEventSourceMapping
s {$sel:uuid:GetEventSourceMapping' :: Text
uuid = Text
a} :: GetEventSourceMapping)

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

instance Prelude.Hashable GetEventSourceMapping

instance Prelude.NFData GetEventSourceMapping

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

instance Core.ToPath GetEventSourceMapping where
  toPath :: GetEventSourceMapping -> ByteString
toPath GetEventSourceMapping' {Text
uuid :: Text
$sel:uuid:GetEventSourceMapping' :: GetEventSourceMapping -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2015-03-31/event-source-mappings/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
uuid
      ]

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