{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 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:/ '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
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]
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
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. 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'
    { $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 :: Lens' GetFunctionConcurrency Text
getFunctionConcurrency_functionName = 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 :: (Service -> Service)
-> GetFunctionConcurrency -> Request GetFunctionConcurrency
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 GetFunctionConcurrency
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetFunctionConcurrency)))
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 ->
          Maybe Natural -> Int -> GetFunctionConcurrencyResponse
GetFunctionConcurrencyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ReservedConcurrentExecutions")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetFunctionConcurrency where
  hashWithSalt :: Int -> GetFunctionConcurrency -> Int
hashWithSalt Int
_salt GetFunctionConcurrency' {Text
functionName :: Text
$sel:functionName:GetFunctionConcurrency' :: GetFunctionConcurrency -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
functionName

instance Prelude.NFData GetFunctionConcurrency where
  rnf :: GetFunctionConcurrency -> ()
rnf GetFunctionConcurrency' {Text
functionName :: Text
$sel:functionName:GetFunctionConcurrency' :: GetFunctionConcurrency -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
functionName

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

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

instance Data.ToQuery GetFunctionConcurrency where
  toQuery :: GetFunctionConcurrency -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:reservedConcurrentExecutions:GetFunctionConcurrencyResponse' :: Maybe Natural
reservedConcurrentExecutions =
        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 :: Lens' GetFunctionConcurrencyResponse (Maybe Natural)
getFunctionConcurrencyResponse_reservedConcurrentExecutions = 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 :: Lens' GetFunctionConcurrencyResponse Int
getFunctionConcurrencyResponse_httpStatus = 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
  where
  rnf :: GetFunctionConcurrencyResponse -> ()
rnf GetFunctionConcurrencyResponse' {Int
Maybe Natural
httpStatus :: Int
reservedConcurrentExecutions :: Maybe Natural
$sel:httpStatus:GetFunctionConcurrencyResponse' :: GetFunctionConcurrencyResponse -> Int
$sel:reservedConcurrentExecutions:GetFunctionConcurrencyResponse' :: GetFunctionConcurrencyResponse -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
reservedConcurrentExecutions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus