{-# 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.GetFunctionConcurrency
-- 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 the reserved concurrency configuration for a
-- function. To set a concurrency limit for a function, use
-- PutFunctionConcurrency.
module Amazonka.Lambda.GetFunctionConcurrency
  ( -- * Creating a Request
    GetFunctionConcurrency (..),
    newGetFunctionConcurrency,

    -- * Request Lenses
    getFunctionConcurrency_functionName,

    -- * Destructuring the Response
    GetFunctionConcurrencyResponse (..),
    newGetFunctionConcurrencyResponse,

    -- * Response Lenses
    getFunctionConcurrencyResponse_reservedConcurrentExecutions,
    getFunctionConcurrencyResponse_httpStatus,
  )
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:/ 'newGetFunctionConcurrency' smart constructor.
data GetFunctionConcurrency = GetFunctionConcurrency'
  { -- | The name of the Lambda function.
    --
    -- __Name formats__
    --
    -- -   __Function name__ - @my-function@.
    --
    -- -   __Function ARN__ -
    --     @arn:aws:lambda:us-west-2:123456789012:function:my-function@.
    --
    -- -   __Partial ARN__ - @123456789012:function:my-function@.
    --
    -- The length constraint applies only to the full ARN. If you specify only
    -- the function name, it is limited to 64 characters in length.
    GetFunctionConcurrency -> Text
functionName :: Prelude.Text
  }
  deriving (GetFunctionConcurrency -> GetFunctionConcurrency -> Bool
(GetFunctionConcurrency -> GetFunctionConcurrency -> Bool)
-> (GetFunctionConcurrency -> GetFunctionConcurrency -> Bool)
-> Eq GetFunctionConcurrency
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFunctionConcurrency -> GetFunctionConcurrency -> Bool
$c/= :: GetFunctionConcurrency -> GetFunctionConcurrency -> Bool
== :: GetFunctionConcurrency -> GetFunctionConcurrency -> Bool
$c== :: GetFunctionConcurrency -> GetFunctionConcurrency -> Bool
Prelude.Eq, ReadPrec [GetFunctionConcurrency]
ReadPrec GetFunctionConcurrency
Int -> ReadS GetFunctionConcurrency
ReadS [GetFunctionConcurrency]
(Int -> ReadS GetFunctionConcurrency)
-> ReadS [GetFunctionConcurrency]
-> ReadPrec GetFunctionConcurrency
-> ReadPrec [GetFunctionConcurrency]
-> Read GetFunctionConcurrency
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFunctionConcurrency]
$creadListPrec :: ReadPrec [GetFunctionConcurrency]
readPrec :: ReadPrec GetFunctionConcurrency
$creadPrec :: ReadPrec GetFunctionConcurrency
readList :: ReadS [GetFunctionConcurrency]
$creadList :: ReadS [GetFunctionConcurrency]
readsPrec :: Int -> ReadS GetFunctionConcurrency
$creadsPrec :: Int -> ReadS GetFunctionConcurrency
Prelude.Read, Int -> GetFunctionConcurrency -> ShowS
[GetFunctionConcurrency] -> ShowS
GetFunctionConcurrency -> String
(Int -> GetFunctionConcurrency -> ShowS)
-> (GetFunctionConcurrency -> String)
-> ([GetFunctionConcurrency] -> ShowS)
-> Show GetFunctionConcurrency
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFunctionConcurrency] -> ShowS
$cshowList :: [GetFunctionConcurrency] -> ShowS
show :: GetFunctionConcurrency -> String
$cshow :: GetFunctionConcurrency -> String
showsPrec :: Int -> GetFunctionConcurrency -> ShowS
$cshowsPrec :: Int -> GetFunctionConcurrency -> ShowS
Prelude.Show, (forall x. GetFunctionConcurrency -> Rep GetFunctionConcurrency x)
-> (forall x.
    Rep GetFunctionConcurrency x -> GetFunctionConcurrency)
-> Generic GetFunctionConcurrency
forall x. Rep GetFunctionConcurrency x -> GetFunctionConcurrency
forall x. GetFunctionConcurrency -> Rep GetFunctionConcurrency x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFunctionConcurrency x -> GetFunctionConcurrency
$cfrom :: forall x. GetFunctionConcurrency -> Rep GetFunctionConcurrency x
Prelude.Generic)

-- |
-- Create a value of 'GetFunctionConcurrency' 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', 'getFunctionConcurrency_functionName' - The name of the Lambda function.
--
-- __Name formats__
--
-- -   __Function name__ - @my-function@.
--
-- -   __Function ARN__ -
--     @arn:aws:lambda:us-west-2:123456789012:function:my-function@.
--
-- -   __Partial ARN__ - @123456789012:function:my-function@.
--
-- The length constraint applies only to the full ARN. If you specify only
-- the function name, it is limited to 64 characters in length.
newGetFunctionConcurrency ::
  -- | 'functionName'
  Prelude.Text ->
  GetFunctionConcurrency
newGetFunctionConcurrency :: Text -> GetFunctionConcurrency
newGetFunctionConcurrency Text
pFunctionName_ =
  GetFunctionConcurrency' :: Text -> GetFunctionConcurrency
GetFunctionConcurrency'
    { $sel:functionName:GetFunctionConcurrency' :: Text
functionName =
        Text
pFunctionName_
    }

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

instance Core.AWSRequest GetFunctionConcurrency where
  type
    AWSResponse GetFunctionConcurrency =
      GetFunctionConcurrencyResponse
  request :: GetFunctionConcurrency -> Request GetFunctionConcurrency
request = Service -> GetFunctionConcurrency -> Request GetFunctionConcurrency
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetFunctionConcurrency
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFunctionConcurrency)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetFunctionConcurrency))
-> Logger
-> Service
-> Proxy GetFunctionConcurrency
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFunctionConcurrency)))
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 ->
          Maybe Natural -> Int -> GetFunctionConcurrencyResponse
GetFunctionConcurrencyResponse'
            (Maybe Natural -> Int -> GetFunctionConcurrencyResponse)
-> Either String (Maybe Natural)
-> Either String (Int -> GetFunctionConcurrencyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ReservedConcurrentExecutions")
            Either String (Int -> GetFunctionConcurrencyResponse)
-> Either String Int
-> Either String GetFunctionConcurrencyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetFunctionConcurrency

instance Prelude.NFData GetFunctionConcurrency

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

instance Core.ToPath GetFunctionConcurrency where
  toPath :: GetFunctionConcurrency -> ByteString
toPath GetFunctionConcurrency' {Text
functionName :: Text
$sel:functionName:GetFunctionConcurrency' :: GetFunctionConcurrency -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2019-09-30/functions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
functionName,
        ByteString
"/concurrency"
      ]

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

-- | /See:/ 'newGetFunctionConcurrencyResponse' smart constructor.
data GetFunctionConcurrencyResponse = GetFunctionConcurrencyResponse'
  { -- | The number of simultaneous executions that are reserved for the
    -- function.
    GetFunctionConcurrencyResponse -> Maybe Natural
reservedConcurrentExecutions :: Prelude.Maybe Prelude.Natural,
    -- | The response's http status code.
    GetFunctionConcurrencyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetFunctionConcurrencyResponse
-> GetFunctionConcurrencyResponse -> Bool
(GetFunctionConcurrencyResponse
 -> GetFunctionConcurrencyResponse -> Bool)
-> (GetFunctionConcurrencyResponse
    -> GetFunctionConcurrencyResponse -> Bool)
-> Eq GetFunctionConcurrencyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFunctionConcurrencyResponse
-> GetFunctionConcurrencyResponse -> Bool
$c/= :: GetFunctionConcurrencyResponse
-> GetFunctionConcurrencyResponse -> Bool
== :: GetFunctionConcurrencyResponse
-> GetFunctionConcurrencyResponse -> Bool
$c== :: GetFunctionConcurrencyResponse
-> GetFunctionConcurrencyResponse -> Bool
Prelude.Eq, ReadPrec [GetFunctionConcurrencyResponse]
ReadPrec GetFunctionConcurrencyResponse
Int -> ReadS GetFunctionConcurrencyResponse
ReadS [GetFunctionConcurrencyResponse]
(Int -> ReadS GetFunctionConcurrencyResponse)
-> ReadS [GetFunctionConcurrencyResponse]
-> ReadPrec GetFunctionConcurrencyResponse
-> ReadPrec [GetFunctionConcurrencyResponse]
-> Read GetFunctionConcurrencyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFunctionConcurrencyResponse]
$creadListPrec :: ReadPrec [GetFunctionConcurrencyResponse]
readPrec :: ReadPrec GetFunctionConcurrencyResponse
$creadPrec :: ReadPrec GetFunctionConcurrencyResponse
readList :: ReadS [GetFunctionConcurrencyResponse]
$creadList :: ReadS [GetFunctionConcurrencyResponse]
readsPrec :: Int -> ReadS GetFunctionConcurrencyResponse
$creadsPrec :: Int -> ReadS GetFunctionConcurrencyResponse
Prelude.Read, Int -> GetFunctionConcurrencyResponse -> ShowS
[GetFunctionConcurrencyResponse] -> ShowS
GetFunctionConcurrencyResponse -> String
(Int -> GetFunctionConcurrencyResponse -> ShowS)
-> (GetFunctionConcurrencyResponse -> String)
-> ([GetFunctionConcurrencyResponse] -> ShowS)
-> Show GetFunctionConcurrencyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFunctionConcurrencyResponse] -> ShowS
$cshowList :: [GetFunctionConcurrencyResponse] -> ShowS
show :: GetFunctionConcurrencyResponse -> String
$cshow :: GetFunctionConcurrencyResponse -> String
showsPrec :: Int -> GetFunctionConcurrencyResponse -> ShowS
$cshowsPrec :: Int -> GetFunctionConcurrencyResponse -> ShowS
Prelude.Show, (forall x.
 GetFunctionConcurrencyResponse
 -> Rep GetFunctionConcurrencyResponse x)
-> (forall x.
    Rep GetFunctionConcurrencyResponse x
    -> GetFunctionConcurrencyResponse)
-> Generic GetFunctionConcurrencyResponse
forall x.
Rep GetFunctionConcurrencyResponse x
-> GetFunctionConcurrencyResponse
forall x.
GetFunctionConcurrencyResponse
-> Rep GetFunctionConcurrencyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetFunctionConcurrencyResponse x
-> GetFunctionConcurrencyResponse
$cfrom :: forall x.
GetFunctionConcurrencyResponse
-> Rep GetFunctionConcurrencyResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetFunctionConcurrencyResponse' 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:
--
-- 'reservedConcurrentExecutions', 'getFunctionConcurrencyResponse_reservedConcurrentExecutions' - The number of simultaneous executions that are reserved for the
-- function.
--
-- 'httpStatus', 'getFunctionConcurrencyResponse_httpStatus' - The response's http status code.
newGetFunctionConcurrencyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetFunctionConcurrencyResponse
newGetFunctionConcurrencyResponse :: Int -> GetFunctionConcurrencyResponse
newGetFunctionConcurrencyResponse Int
pHttpStatus_ =
  GetFunctionConcurrencyResponse' :: Maybe Natural -> Int -> GetFunctionConcurrencyResponse
GetFunctionConcurrencyResponse'
    { $sel:reservedConcurrentExecutions:GetFunctionConcurrencyResponse' :: Maybe Natural
reservedConcurrentExecutions =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetFunctionConcurrencyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The number of simultaneous executions that are reserved for the
-- function.
getFunctionConcurrencyResponse_reservedConcurrentExecutions :: Lens.Lens' GetFunctionConcurrencyResponse (Prelude.Maybe Prelude.Natural)
getFunctionConcurrencyResponse_reservedConcurrentExecutions :: (Maybe Natural -> f (Maybe Natural))
-> GetFunctionConcurrencyResponse
-> f GetFunctionConcurrencyResponse
getFunctionConcurrencyResponse_reservedConcurrentExecutions = (GetFunctionConcurrencyResponse -> Maybe Natural)
-> (GetFunctionConcurrencyResponse
    -> Maybe Natural -> GetFunctionConcurrencyResponse)
-> Lens
     GetFunctionConcurrencyResponse
     GetFunctionConcurrencyResponse
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFunctionConcurrencyResponse' {Maybe Natural
reservedConcurrentExecutions :: Maybe Natural
$sel:reservedConcurrentExecutions:GetFunctionConcurrencyResponse' :: GetFunctionConcurrencyResponse -> Maybe Natural
reservedConcurrentExecutions} -> Maybe Natural
reservedConcurrentExecutions) (\s :: GetFunctionConcurrencyResponse
s@GetFunctionConcurrencyResponse' {} Maybe Natural
a -> GetFunctionConcurrencyResponse
s {$sel:reservedConcurrentExecutions:GetFunctionConcurrencyResponse' :: Maybe Natural
reservedConcurrentExecutions = Maybe Natural
a} :: GetFunctionConcurrencyResponse)

-- | The response's http status code.
getFunctionConcurrencyResponse_httpStatus :: Lens.Lens' GetFunctionConcurrencyResponse Prelude.Int
getFunctionConcurrencyResponse_httpStatus :: (Int -> f Int)
-> GetFunctionConcurrencyResponse
-> f GetFunctionConcurrencyResponse
getFunctionConcurrencyResponse_httpStatus = (GetFunctionConcurrencyResponse -> Int)
-> (GetFunctionConcurrencyResponse
    -> Int -> GetFunctionConcurrencyResponse)
-> Lens
     GetFunctionConcurrencyResponse
     GetFunctionConcurrencyResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFunctionConcurrencyResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetFunctionConcurrencyResponse' :: GetFunctionConcurrencyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetFunctionConcurrencyResponse
s@GetFunctionConcurrencyResponse' {} Int
a -> GetFunctionConcurrencyResponse
s {$sel:httpStatus:GetFunctionConcurrencyResponse' :: Int
httpStatus = Int
a} :: GetFunctionConcurrencyResponse)

instance
  Prelude.NFData
    GetFunctionConcurrencyResponse