{-# 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 #-}
module Amazonka.APIGateway.CreateUsagePlan
(
CreateUsagePlan (..),
newCreateUsagePlan,
createUsagePlan_apiStages,
createUsagePlan_description,
createUsagePlan_quota,
createUsagePlan_tags,
createUsagePlan_throttle,
createUsagePlan_name,
UsagePlan (..),
newUsagePlan,
usagePlan_apiStages,
usagePlan_description,
usagePlan_id,
usagePlan_name,
usagePlan_productCode,
usagePlan_quota,
usagePlan_tags,
usagePlan_throttle,
)
where
import Amazonka.APIGateway.Types
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateUsagePlan = CreateUsagePlan'
{
CreateUsagePlan -> Maybe [ApiStage]
apiStages :: Prelude.Maybe [ApiStage],
CreateUsagePlan -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateUsagePlan -> Maybe QuotaSettings
quota :: Prelude.Maybe QuotaSettings,
CreateUsagePlan -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateUsagePlan -> Maybe ThrottleSettings
throttle :: Prelude.Maybe ThrottleSettings,
CreateUsagePlan -> Text
name :: Prelude.Text
}
deriving (CreateUsagePlan -> CreateUsagePlan -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateUsagePlan -> CreateUsagePlan -> Bool
$c/= :: CreateUsagePlan -> CreateUsagePlan -> Bool
== :: CreateUsagePlan -> CreateUsagePlan -> Bool
$c== :: CreateUsagePlan -> CreateUsagePlan -> Bool
Prelude.Eq, ReadPrec [CreateUsagePlan]
ReadPrec CreateUsagePlan
Int -> ReadS CreateUsagePlan
ReadS [CreateUsagePlan]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateUsagePlan]
$creadListPrec :: ReadPrec [CreateUsagePlan]
readPrec :: ReadPrec CreateUsagePlan
$creadPrec :: ReadPrec CreateUsagePlan
readList :: ReadS [CreateUsagePlan]
$creadList :: ReadS [CreateUsagePlan]
readsPrec :: Int -> ReadS CreateUsagePlan
$creadsPrec :: Int -> ReadS CreateUsagePlan
Prelude.Read, Int -> CreateUsagePlan -> ShowS
[CreateUsagePlan] -> ShowS
CreateUsagePlan -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateUsagePlan] -> ShowS
$cshowList :: [CreateUsagePlan] -> ShowS
show :: CreateUsagePlan -> String
$cshow :: CreateUsagePlan -> String
showsPrec :: Int -> CreateUsagePlan -> ShowS
$cshowsPrec :: Int -> CreateUsagePlan -> ShowS
Prelude.Show, forall x. Rep CreateUsagePlan x -> CreateUsagePlan
forall x. CreateUsagePlan -> Rep CreateUsagePlan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateUsagePlan x -> CreateUsagePlan
$cfrom :: forall x. CreateUsagePlan -> Rep CreateUsagePlan x
Prelude.Generic)
newCreateUsagePlan ::
Prelude.Text ->
CreateUsagePlan
newCreateUsagePlan :: Text -> CreateUsagePlan
newCreateUsagePlan Text
pName_ =
CreateUsagePlan'
{ $sel:apiStages:CreateUsagePlan' :: Maybe [ApiStage]
apiStages = forall a. Maybe a
Prelude.Nothing,
$sel:description:CreateUsagePlan' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
$sel:quota:CreateUsagePlan' :: Maybe QuotaSettings
quota = forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateUsagePlan' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
$sel:throttle:CreateUsagePlan' :: Maybe ThrottleSettings
throttle = forall a. Maybe a
Prelude.Nothing,
$sel:name:CreateUsagePlan' :: Text
name = Text
pName_
}
createUsagePlan_apiStages :: Lens.Lens' CreateUsagePlan (Prelude.Maybe [ApiStage])
createUsagePlan_apiStages :: Lens' CreateUsagePlan (Maybe [ApiStage])
createUsagePlan_apiStages = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsagePlan' {Maybe [ApiStage]
apiStages :: Maybe [ApiStage]
$sel:apiStages:CreateUsagePlan' :: CreateUsagePlan -> Maybe [ApiStage]
apiStages} -> Maybe [ApiStage]
apiStages) (\s :: CreateUsagePlan
s@CreateUsagePlan' {} Maybe [ApiStage]
a -> CreateUsagePlan
s {$sel:apiStages:CreateUsagePlan' :: Maybe [ApiStage]
apiStages = Maybe [ApiStage]
a} :: CreateUsagePlan) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createUsagePlan_description :: Lens.Lens' CreateUsagePlan (Prelude.Maybe Prelude.Text)
createUsagePlan_description :: Lens' CreateUsagePlan (Maybe Text)
createUsagePlan_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsagePlan' {Maybe Text
description :: Maybe Text
$sel:description:CreateUsagePlan' :: CreateUsagePlan -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateUsagePlan
s@CreateUsagePlan' {} Maybe Text
a -> CreateUsagePlan
s {$sel:description:CreateUsagePlan' :: Maybe Text
description = Maybe Text
a} :: CreateUsagePlan)
createUsagePlan_quota :: Lens.Lens' CreateUsagePlan (Prelude.Maybe QuotaSettings)
createUsagePlan_quota :: Lens' CreateUsagePlan (Maybe QuotaSettings)
createUsagePlan_quota = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsagePlan' {Maybe QuotaSettings
quota :: Maybe QuotaSettings
$sel:quota:CreateUsagePlan' :: CreateUsagePlan -> Maybe QuotaSettings
quota} -> Maybe QuotaSettings
quota) (\s :: CreateUsagePlan
s@CreateUsagePlan' {} Maybe QuotaSettings
a -> CreateUsagePlan
s {$sel:quota:CreateUsagePlan' :: Maybe QuotaSettings
quota = Maybe QuotaSettings
a} :: CreateUsagePlan)
createUsagePlan_tags :: Lens.Lens' CreateUsagePlan (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createUsagePlan_tags :: Lens' CreateUsagePlan (Maybe (HashMap Text Text))
createUsagePlan_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsagePlan' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateUsagePlan' :: CreateUsagePlan -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateUsagePlan
s@CreateUsagePlan' {} Maybe (HashMap Text Text)
a -> CreateUsagePlan
s {$sel:tags:CreateUsagePlan' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateUsagePlan) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createUsagePlan_throttle :: Lens.Lens' CreateUsagePlan (Prelude.Maybe ThrottleSettings)
createUsagePlan_throttle :: Lens' CreateUsagePlan (Maybe ThrottleSettings)
createUsagePlan_throttle = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsagePlan' {Maybe ThrottleSettings
throttle :: Maybe ThrottleSettings
$sel:throttle:CreateUsagePlan' :: CreateUsagePlan -> Maybe ThrottleSettings
throttle} -> Maybe ThrottleSettings
throttle) (\s :: CreateUsagePlan
s@CreateUsagePlan' {} Maybe ThrottleSettings
a -> CreateUsagePlan
s {$sel:throttle:CreateUsagePlan' :: Maybe ThrottleSettings
throttle = Maybe ThrottleSettings
a} :: CreateUsagePlan)
createUsagePlan_name :: Lens.Lens' CreateUsagePlan Prelude.Text
createUsagePlan_name :: Lens' CreateUsagePlan Text
createUsagePlan_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsagePlan' {Text
name :: Text
$sel:name:CreateUsagePlan' :: CreateUsagePlan -> Text
name} -> Text
name) (\s :: CreateUsagePlan
s@CreateUsagePlan' {} Text
a -> CreateUsagePlan
s {$sel:name:CreateUsagePlan' :: Text
name = Text
a} :: CreateUsagePlan)
instance Core.AWSRequest CreateUsagePlan where
type AWSResponse CreateUsagePlan = UsagePlan
request :: (Service -> Service) -> CreateUsagePlan -> Request CreateUsagePlan
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateUsagePlan
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateUsagePlan)))
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 CreateUsagePlan where
hashWithSalt :: Int -> CreateUsagePlan -> Int
hashWithSalt Int
_salt CreateUsagePlan' {Maybe [ApiStage]
Maybe Text
Maybe (HashMap Text Text)
Maybe QuotaSettings
Maybe ThrottleSettings
Text
name :: Text
throttle :: Maybe ThrottleSettings
tags :: Maybe (HashMap Text Text)
quota :: Maybe QuotaSettings
description :: Maybe Text
apiStages :: Maybe [ApiStage]
$sel:name:CreateUsagePlan' :: CreateUsagePlan -> Text
$sel:throttle:CreateUsagePlan' :: CreateUsagePlan -> Maybe ThrottleSettings
$sel:tags:CreateUsagePlan' :: CreateUsagePlan -> Maybe (HashMap Text Text)
$sel:quota:CreateUsagePlan' :: CreateUsagePlan -> Maybe QuotaSettings
$sel:description:CreateUsagePlan' :: CreateUsagePlan -> Maybe Text
$sel:apiStages:CreateUsagePlan' :: CreateUsagePlan -> Maybe [ApiStage]
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ApiStage]
apiStages
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QuotaSettings
quota
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ThrottleSettings
throttle
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
instance Prelude.NFData CreateUsagePlan where
rnf :: CreateUsagePlan -> ()
rnf CreateUsagePlan' {Maybe [ApiStage]
Maybe Text
Maybe (HashMap Text Text)
Maybe QuotaSettings
Maybe ThrottleSettings
Text
name :: Text
throttle :: Maybe ThrottleSettings
tags :: Maybe (HashMap Text Text)
quota :: Maybe QuotaSettings
description :: Maybe Text
apiStages :: Maybe [ApiStage]
$sel:name:CreateUsagePlan' :: CreateUsagePlan -> Text
$sel:throttle:CreateUsagePlan' :: CreateUsagePlan -> Maybe ThrottleSettings
$sel:tags:CreateUsagePlan' :: CreateUsagePlan -> Maybe (HashMap Text Text)
$sel:quota:CreateUsagePlan' :: CreateUsagePlan -> Maybe QuotaSettings
$sel:description:CreateUsagePlan' :: CreateUsagePlan -> Maybe Text
$sel:apiStages:CreateUsagePlan' :: CreateUsagePlan -> Maybe [ApiStage]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [ApiStage]
apiStages
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe QuotaSettings
quota
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ThrottleSettings
throttle
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
instance Data.ToHeaders CreateUsagePlan where
toHeaders :: CreateUsagePlan -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Accept"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
]
)
instance Data.ToJSON CreateUsagePlan where
toJSON :: CreateUsagePlan -> Value
toJSON CreateUsagePlan' {Maybe [ApiStage]
Maybe Text
Maybe (HashMap Text Text)
Maybe QuotaSettings
Maybe ThrottleSettings
Text
name :: Text
throttle :: Maybe ThrottleSettings
tags :: Maybe (HashMap Text Text)
quota :: Maybe QuotaSettings
description :: Maybe Text
apiStages :: Maybe [ApiStage]
$sel:name:CreateUsagePlan' :: CreateUsagePlan -> Text
$sel:throttle:CreateUsagePlan' :: CreateUsagePlan -> Maybe ThrottleSettings
$sel:tags:CreateUsagePlan' :: CreateUsagePlan -> Maybe (HashMap Text Text)
$sel:quota:CreateUsagePlan' :: CreateUsagePlan -> Maybe QuotaSettings
$sel:description:CreateUsagePlan' :: CreateUsagePlan -> Maybe Text
$sel:apiStages:CreateUsagePlan' :: CreateUsagePlan -> Maybe [ApiStage]
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"apiStages" 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 [ApiStage]
apiStages,
(Key
"description" 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 Text
description,
(Key
"quota" 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 QuotaSettings
quota,
(Key
"tags" 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 (HashMap Text Text)
tags,
(Key
"throttle" 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 ThrottleSettings
throttle,
forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
]
)
instance Data.ToPath CreateUsagePlan where
toPath :: CreateUsagePlan -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/usageplans"
instance Data.ToQuery CreateUsagePlan where
toQuery :: CreateUsagePlan -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty