{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.APIGateway.Types.ThrottleSettings where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
data ThrottleSettings = ThrottleSettings'
{
ThrottleSettings -> Maybe Int
burstLimit :: Prelude.Maybe Prelude.Int,
ThrottleSettings -> Maybe Double
rateLimit :: Prelude.Maybe Prelude.Double
}
deriving (ThrottleSettings -> ThrottleSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThrottleSettings -> ThrottleSettings -> Bool
$c/= :: ThrottleSettings -> ThrottleSettings -> Bool
== :: ThrottleSettings -> ThrottleSettings -> Bool
$c== :: ThrottleSettings -> ThrottleSettings -> Bool
Prelude.Eq, ReadPrec [ThrottleSettings]
ReadPrec ThrottleSettings
Int -> ReadS ThrottleSettings
ReadS [ThrottleSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThrottleSettings]
$creadListPrec :: ReadPrec [ThrottleSettings]
readPrec :: ReadPrec ThrottleSettings
$creadPrec :: ReadPrec ThrottleSettings
readList :: ReadS [ThrottleSettings]
$creadList :: ReadS [ThrottleSettings]
readsPrec :: Int -> ReadS ThrottleSettings
$creadsPrec :: Int -> ReadS ThrottleSettings
Prelude.Read, Int -> ThrottleSettings -> ShowS
[ThrottleSettings] -> ShowS
ThrottleSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThrottleSettings] -> ShowS
$cshowList :: [ThrottleSettings] -> ShowS
show :: ThrottleSettings -> String
$cshow :: ThrottleSettings -> String
showsPrec :: Int -> ThrottleSettings -> ShowS
$cshowsPrec :: Int -> ThrottleSettings -> ShowS
Prelude.Show, forall x. Rep ThrottleSettings x -> ThrottleSettings
forall x. ThrottleSettings -> Rep ThrottleSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThrottleSettings x -> ThrottleSettings
$cfrom :: forall x. ThrottleSettings -> Rep ThrottleSettings x
Prelude.Generic)
newThrottleSettings ::
ThrottleSettings
newThrottleSettings :: ThrottleSettings
newThrottleSettings =
ThrottleSettings'
{ $sel:burstLimit:ThrottleSettings' :: Maybe Int
burstLimit = forall a. Maybe a
Prelude.Nothing,
$sel:rateLimit:ThrottleSettings' :: Maybe Double
rateLimit = forall a. Maybe a
Prelude.Nothing
}
throttleSettings_burstLimit :: Lens.Lens' ThrottleSettings (Prelude.Maybe Prelude.Int)
throttleSettings_burstLimit :: Lens' ThrottleSettings (Maybe Int)
throttleSettings_burstLimit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThrottleSettings' {Maybe Int
burstLimit :: Maybe Int
$sel:burstLimit:ThrottleSettings' :: ThrottleSettings -> Maybe Int
burstLimit} -> Maybe Int
burstLimit) (\s :: ThrottleSettings
s@ThrottleSettings' {} Maybe Int
a -> ThrottleSettings
s {$sel:burstLimit:ThrottleSettings' :: Maybe Int
burstLimit = Maybe Int
a} :: ThrottleSettings)
throttleSettings_rateLimit :: Lens.Lens' ThrottleSettings (Prelude.Maybe Prelude.Double)
throttleSettings_rateLimit :: Lens' ThrottleSettings (Maybe Double)
throttleSettings_rateLimit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThrottleSettings' {Maybe Double
rateLimit :: Maybe Double
$sel:rateLimit:ThrottleSettings' :: ThrottleSettings -> Maybe Double
rateLimit} -> Maybe Double
rateLimit) (\s :: ThrottleSettings
s@ThrottleSettings' {} Maybe Double
a -> ThrottleSettings
s {$sel:rateLimit:ThrottleSettings' :: Maybe Double
rateLimit = Maybe Double
a} :: ThrottleSettings)
instance Data.FromJSON ThrottleSettings where
parseJSON :: Value -> Parser ThrottleSettings
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"ThrottleSettings"
( \Object
x ->
Maybe Int -> Maybe Double -> ThrottleSettings
ThrottleSettings'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"burstLimit")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"rateLimit")
)
instance Prelude.Hashable ThrottleSettings where
hashWithSalt :: Int -> ThrottleSettings -> Int
hashWithSalt Int
_salt ThrottleSettings' {Maybe Double
Maybe Int
rateLimit :: Maybe Double
burstLimit :: Maybe Int
$sel:rateLimit:ThrottleSettings' :: ThrottleSettings -> Maybe Double
$sel:burstLimit:ThrottleSettings' :: ThrottleSettings -> Maybe Int
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
burstLimit
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
rateLimit
instance Prelude.NFData ThrottleSettings where
rnf :: ThrottleSettings -> ()
rnf ThrottleSettings' {Maybe Double
Maybe Int
rateLimit :: Maybe Double
burstLimit :: Maybe Int
$sel:rateLimit:ThrottleSettings' :: ThrottleSettings -> Maybe Double
$sel:burstLimit:ThrottleSettings' :: ThrottleSettings -> Maybe Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
burstLimit
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
rateLimit
instance Data.ToJSON ThrottleSettings where
toJSON :: ThrottleSettings -> Value
toJSON ThrottleSettings' {Maybe Double
Maybe Int
rateLimit :: Maybe Double
burstLimit :: Maybe Int
$sel:rateLimit:ThrottleSettings' :: ThrottleSettings -> Maybe Double
$sel:burstLimit:ThrottleSettings' :: ThrottleSettings -> Maybe Int
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"burstLimit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
burstLimit,
(Key
"rateLimit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
rateLimit
]
)