{-# 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_throttle,
createUsagePlan_quota,
createUsagePlan_description,
createUsagePlan_tags,
createUsagePlan_name,
UsagePlan (..),
newUsagePlan,
usagePlan_apiStages,
usagePlan_name,
usagePlan_id,
usagePlan_throttle,
usagePlan_quota,
usagePlan_description,
usagePlan_productCode,
usagePlan_tags,
)
where
import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 ThrottleSettings
throttle :: Prelude.Maybe ThrottleSettings,
CreateUsagePlan -> Maybe QuotaSettings
quota :: Prelude.Maybe QuotaSettings,
CreateUsagePlan -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateUsagePlan -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateUsagePlan -> Text
name :: Prelude.Text
}
deriving (CreateUsagePlan -> CreateUsagePlan -> Bool
(CreateUsagePlan -> CreateUsagePlan -> Bool)
-> (CreateUsagePlan -> CreateUsagePlan -> Bool)
-> Eq CreateUsagePlan
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]
(Int -> ReadS CreateUsagePlan)
-> ReadS [CreateUsagePlan]
-> ReadPrec CreateUsagePlan
-> ReadPrec [CreateUsagePlan]
-> Read 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
(Int -> CreateUsagePlan -> ShowS)
-> (CreateUsagePlan -> String)
-> ([CreateUsagePlan] -> ShowS)
-> Show CreateUsagePlan
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. CreateUsagePlan -> Rep CreateUsagePlan x)
-> (forall x. Rep CreateUsagePlan x -> CreateUsagePlan)
-> Generic CreateUsagePlan
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' :: Maybe [ApiStage]
-> Maybe ThrottleSettings
-> Maybe QuotaSettings
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> CreateUsagePlan
CreateUsagePlan'
{ $sel:apiStages:CreateUsagePlan' :: Maybe [ApiStage]
apiStages = Maybe [ApiStage]
forall a. Maybe a
Prelude.Nothing,
$sel:throttle:CreateUsagePlan' :: Maybe ThrottleSettings
throttle = Maybe ThrottleSettings
forall a. Maybe a
Prelude.Nothing,
$sel:quota:CreateUsagePlan' :: Maybe QuotaSettings
quota = Maybe QuotaSettings
forall a. Maybe a
Prelude.Nothing,
$sel:description:CreateUsagePlan' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateUsagePlan' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:name:CreateUsagePlan' :: Text
name = Text
pName_
}
createUsagePlan_apiStages :: Lens.Lens' CreateUsagePlan (Prelude.Maybe [ApiStage])
createUsagePlan_apiStages :: (Maybe [ApiStage] -> f (Maybe [ApiStage]))
-> CreateUsagePlan -> f CreateUsagePlan
createUsagePlan_apiStages = (CreateUsagePlan -> Maybe [ApiStage])
-> (CreateUsagePlan -> Maybe [ApiStage] -> CreateUsagePlan)
-> Lens
CreateUsagePlan
CreateUsagePlan
(Maybe [ApiStage])
(Maybe [ApiStage])
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) ((Maybe [ApiStage] -> f (Maybe [ApiStage]))
-> CreateUsagePlan -> f CreateUsagePlan)
-> ((Maybe [ApiStage] -> f (Maybe [ApiStage]))
-> Maybe [ApiStage] -> f (Maybe [ApiStage]))
-> (Maybe [ApiStage] -> f (Maybe [ApiStage]))
-> CreateUsagePlan
-> f CreateUsagePlan
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ApiStage] [ApiStage] [ApiStage] [ApiStage]
-> Iso
(Maybe [ApiStage])
(Maybe [ApiStage])
(Maybe [ApiStage])
(Maybe [ApiStage])
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 AnIso [ApiStage] [ApiStage] [ApiStage] [ApiStage]
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 :: (Maybe ThrottleSettings -> f (Maybe ThrottleSettings))
-> CreateUsagePlan -> f CreateUsagePlan
createUsagePlan_throttle = (CreateUsagePlan -> Maybe ThrottleSettings)
-> (CreateUsagePlan -> Maybe ThrottleSettings -> CreateUsagePlan)
-> Lens
CreateUsagePlan
CreateUsagePlan
(Maybe ThrottleSettings)
(Maybe ThrottleSettings)
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_quota :: Lens.Lens' CreateUsagePlan (Prelude.Maybe QuotaSettings)
createUsagePlan_quota :: (Maybe QuotaSettings -> f (Maybe QuotaSettings))
-> CreateUsagePlan -> f CreateUsagePlan
createUsagePlan_quota = (CreateUsagePlan -> Maybe QuotaSettings)
-> (CreateUsagePlan -> Maybe QuotaSettings -> CreateUsagePlan)
-> Lens
CreateUsagePlan
CreateUsagePlan
(Maybe QuotaSettings)
(Maybe QuotaSettings)
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_description :: Lens.Lens' CreateUsagePlan (Prelude.Maybe Prelude.Text)
createUsagePlan_description :: (Maybe Text -> f (Maybe Text))
-> CreateUsagePlan -> f CreateUsagePlan
createUsagePlan_description = (CreateUsagePlan -> Maybe Text)
-> (CreateUsagePlan -> Maybe Text -> CreateUsagePlan)
-> Lens CreateUsagePlan CreateUsagePlan (Maybe Text) (Maybe Text)
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_tags :: Lens.Lens' CreateUsagePlan (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createUsagePlan_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateUsagePlan -> f CreateUsagePlan
createUsagePlan_tags = (CreateUsagePlan -> Maybe (HashMap Text Text))
-> (CreateUsagePlan
-> Maybe (HashMap Text Text) -> CreateUsagePlan)
-> Lens
CreateUsagePlan
CreateUsagePlan
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateUsagePlan -> f CreateUsagePlan)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateUsagePlan
-> f CreateUsagePlan
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
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 AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createUsagePlan_name :: Lens.Lens' CreateUsagePlan Prelude.Text
createUsagePlan_name :: (Text -> f Text) -> CreateUsagePlan -> f CreateUsagePlan
createUsagePlan_name = (CreateUsagePlan -> Text)
-> (CreateUsagePlan -> Text -> CreateUsagePlan)
-> Lens CreateUsagePlan CreateUsagePlan Text Text
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 :: CreateUsagePlan -> Request CreateUsagePlan
request = Service -> CreateUsagePlan -> Request CreateUsagePlan
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateUsagePlan
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateUsagePlan)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateUsagePlan))
-> Logger
-> Service
-> Proxy CreateUsagePlan
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateUsagePlan)))
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 UsagePlan
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
instance Prelude.Hashable CreateUsagePlan
instance Prelude.NFData CreateUsagePlan
instance Core.ToHeaders CreateUsagePlan where
toHeaders :: CreateUsagePlan -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateUsagePlan -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Accept"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"application/json" :: Prelude.ByteString)
]
)
instance Core.ToJSON CreateUsagePlan where
toJSON :: CreateUsagePlan -> Value
toJSON CreateUsagePlan' {Maybe [ApiStage]
Maybe Text
Maybe (HashMap Text Text)
Maybe QuotaSettings
Maybe ThrottleSettings
Text
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
quota :: Maybe QuotaSettings
throttle :: Maybe ThrottleSettings
apiStages :: Maybe [ApiStage]
$sel:name:CreateUsagePlan' :: CreateUsagePlan -> Text
$sel:tags:CreateUsagePlan' :: CreateUsagePlan -> Maybe (HashMap Text Text)
$sel:description:CreateUsagePlan' :: CreateUsagePlan -> Maybe Text
$sel:quota:CreateUsagePlan' :: CreateUsagePlan -> Maybe QuotaSettings
$sel:throttle:CreateUsagePlan' :: CreateUsagePlan -> Maybe ThrottleSettings
$sel:apiStages:CreateUsagePlan' :: CreateUsagePlan -> Maybe [ApiStage]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"apiStages" Text -> [ApiStage] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ApiStage] -> Pair) -> Maybe [ApiStage] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ApiStage]
apiStages,
(Text
"throttle" Text -> ThrottleSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ThrottleSettings -> Pair) -> Maybe ThrottleSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ThrottleSettings
throttle,
(Text
"quota" Text -> QuotaSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (QuotaSettings -> Pair) -> Maybe QuotaSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe QuotaSettings
quota,
(Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
(Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
]
)
instance Core.ToPath CreateUsagePlan where
toPath :: CreateUsagePlan -> ByteString
toPath = ByteString -> CreateUsagePlan -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/usageplans"
instance Core.ToQuery CreateUsagePlan where
toQuery :: CreateUsagePlan -> QueryString
toQuery = QueryString -> CreateUsagePlan -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty