{-# 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.CreateUsagePlanKey
(
CreateUsagePlanKey (..),
newCreateUsagePlanKey,
createUsagePlanKey_usagePlanId,
createUsagePlanKey_keyId,
createUsagePlanKey_keyType,
UsagePlanKey (..),
newUsagePlanKey,
usagePlanKey_value,
usagePlanKey_name,
usagePlanKey_id,
usagePlanKey_type,
)
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 CreateUsagePlanKey = CreateUsagePlanKey'
{
CreateUsagePlanKey -> Text
usagePlanId :: Prelude.Text,
CreateUsagePlanKey -> Text
keyId :: Prelude.Text,
CreateUsagePlanKey -> Text
keyType :: Prelude.Text
}
deriving (CreateUsagePlanKey -> CreateUsagePlanKey -> Bool
(CreateUsagePlanKey -> CreateUsagePlanKey -> Bool)
-> (CreateUsagePlanKey -> CreateUsagePlanKey -> Bool)
-> Eq CreateUsagePlanKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateUsagePlanKey -> CreateUsagePlanKey -> Bool
$c/= :: CreateUsagePlanKey -> CreateUsagePlanKey -> Bool
== :: CreateUsagePlanKey -> CreateUsagePlanKey -> Bool
$c== :: CreateUsagePlanKey -> CreateUsagePlanKey -> Bool
Prelude.Eq, ReadPrec [CreateUsagePlanKey]
ReadPrec CreateUsagePlanKey
Int -> ReadS CreateUsagePlanKey
ReadS [CreateUsagePlanKey]
(Int -> ReadS CreateUsagePlanKey)
-> ReadS [CreateUsagePlanKey]
-> ReadPrec CreateUsagePlanKey
-> ReadPrec [CreateUsagePlanKey]
-> Read CreateUsagePlanKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateUsagePlanKey]
$creadListPrec :: ReadPrec [CreateUsagePlanKey]
readPrec :: ReadPrec CreateUsagePlanKey
$creadPrec :: ReadPrec CreateUsagePlanKey
readList :: ReadS [CreateUsagePlanKey]
$creadList :: ReadS [CreateUsagePlanKey]
readsPrec :: Int -> ReadS CreateUsagePlanKey
$creadsPrec :: Int -> ReadS CreateUsagePlanKey
Prelude.Read, Int -> CreateUsagePlanKey -> ShowS
[CreateUsagePlanKey] -> ShowS
CreateUsagePlanKey -> String
(Int -> CreateUsagePlanKey -> ShowS)
-> (CreateUsagePlanKey -> String)
-> ([CreateUsagePlanKey] -> ShowS)
-> Show CreateUsagePlanKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateUsagePlanKey] -> ShowS
$cshowList :: [CreateUsagePlanKey] -> ShowS
show :: CreateUsagePlanKey -> String
$cshow :: CreateUsagePlanKey -> String
showsPrec :: Int -> CreateUsagePlanKey -> ShowS
$cshowsPrec :: Int -> CreateUsagePlanKey -> ShowS
Prelude.Show, (forall x. CreateUsagePlanKey -> Rep CreateUsagePlanKey x)
-> (forall x. Rep CreateUsagePlanKey x -> CreateUsagePlanKey)
-> Generic CreateUsagePlanKey
forall x. Rep CreateUsagePlanKey x -> CreateUsagePlanKey
forall x. CreateUsagePlanKey -> Rep CreateUsagePlanKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateUsagePlanKey x -> CreateUsagePlanKey
$cfrom :: forall x. CreateUsagePlanKey -> Rep CreateUsagePlanKey x
Prelude.Generic)
newCreateUsagePlanKey ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
CreateUsagePlanKey
newCreateUsagePlanKey :: Text -> Text -> Text -> CreateUsagePlanKey
newCreateUsagePlanKey Text
pUsagePlanId_ Text
pKeyId_ Text
pKeyType_ =
CreateUsagePlanKey' :: Text -> Text -> Text -> CreateUsagePlanKey
CreateUsagePlanKey'
{ $sel:usagePlanId:CreateUsagePlanKey' :: Text
usagePlanId = Text
pUsagePlanId_,
$sel:keyId:CreateUsagePlanKey' :: Text
keyId = Text
pKeyId_,
$sel:keyType:CreateUsagePlanKey' :: Text
keyType = Text
pKeyType_
}
createUsagePlanKey_usagePlanId :: Lens.Lens' CreateUsagePlanKey Prelude.Text
createUsagePlanKey_usagePlanId :: (Text -> f Text) -> CreateUsagePlanKey -> f CreateUsagePlanKey
createUsagePlanKey_usagePlanId = (CreateUsagePlanKey -> Text)
-> (CreateUsagePlanKey -> Text -> CreateUsagePlanKey)
-> Lens CreateUsagePlanKey CreateUsagePlanKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsagePlanKey' {Text
usagePlanId :: Text
$sel:usagePlanId:CreateUsagePlanKey' :: CreateUsagePlanKey -> Text
usagePlanId} -> Text
usagePlanId) (\s :: CreateUsagePlanKey
s@CreateUsagePlanKey' {} Text
a -> CreateUsagePlanKey
s {$sel:usagePlanId:CreateUsagePlanKey' :: Text
usagePlanId = Text
a} :: CreateUsagePlanKey)
createUsagePlanKey_keyId :: Lens.Lens' CreateUsagePlanKey Prelude.Text
createUsagePlanKey_keyId :: (Text -> f Text) -> CreateUsagePlanKey -> f CreateUsagePlanKey
createUsagePlanKey_keyId = (CreateUsagePlanKey -> Text)
-> (CreateUsagePlanKey -> Text -> CreateUsagePlanKey)
-> Lens CreateUsagePlanKey CreateUsagePlanKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsagePlanKey' {Text
keyId :: Text
$sel:keyId:CreateUsagePlanKey' :: CreateUsagePlanKey -> Text
keyId} -> Text
keyId) (\s :: CreateUsagePlanKey
s@CreateUsagePlanKey' {} Text
a -> CreateUsagePlanKey
s {$sel:keyId:CreateUsagePlanKey' :: Text
keyId = Text
a} :: CreateUsagePlanKey)
createUsagePlanKey_keyType :: Lens.Lens' CreateUsagePlanKey Prelude.Text
createUsagePlanKey_keyType :: (Text -> f Text) -> CreateUsagePlanKey -> f CreateUsagePlanKey
createUsagePlanKey_keyType = (CreateUsagePlanKey -> Text)
-> (CreateUsagePlanKey -> Text -> CreateUsagePlanKey)
-> Lens CreateUsagePlanKey CreateUsagePlanKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateUsagePlanKey' {Text
keyType :: Text
$sel:keyType:CreateUsagePlanKey' :: CreateUsagePlanKey -> Text
keyType} -> Text
keyType) (\s :: CreateUsagePlanKey
s@CreateUsagePlanKey' {} Text
a -> CreateUsagePlanKey
s {$sel:keyType:CreateUsagePlanKey' :: Text
keyType = Text
a} :: CreateUsagePlanKey)
instance Core.AWSRequest CreateUsagePlanKey where
type AWSResponse CreateUsagePlanKey = UsagePlanKey
request :: CreateUsagePlanKey -> Request CreateUsagePlanKey
request = Service -> CreateUsagePlanKey -> Request CreateUsagePlanKey
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateUsagePlanKey
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateUsagePlanKey)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateUsagePlanKey))
-> Logger
-> Service
-> Proxy CreateUsagePlanKey
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateUsagePlanKey)))
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 UsagePlanKey
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
instance Prelude.Hashable CreateUsagePlanKey
instance Prelude.NFData CreateUsagePlanKey
instance Core.ToHeaders CreateUsagePlanKey where
toHeaders :: CreateUsagePlanKey -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateUsagePlanKey -> 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 CreateUsagePlanKey where
toJSON :: CreateUsagePlanKey -> Value
toJSON CreateUsagePlanKey' {Text
keyType :: Text
keyId :: Text
usagePlanId :: Text
$sel:keyType:CreateUsagePlanKey' :: CreateUsagePlanKey -> Text
$sel:keyId:CreateUsagePlanKey' :: CreateUsagePlanKey -> Text
$sel:usagePlanId:CreateUsagePlanKey' :: CreateUsagePlanKey -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"keyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
keyId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"keyType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
keyType)
]
)
instance Core.ToPath CreateUsagePlanKey where
toPath :: CreateUsagePlanKey -> ByteString
toPath CreateUsagePlanKey' {Text
keyType :: Text
keyId :: Text
usagePlanId :: Text
$sel:keyType:CreateUsagePlanKey' :: CreateUsagePlanKey -> Text
$sel:keyId:CreateUsagePlanKey' :: CreateUsagePlanKey -> Text
$sel:usagePlanId:CreateUsagePlanKey' :: CreateUsagePlanKey -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/usageplans/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
usagePlanId, ByteString
"/keys"]
instance Core.ToQuery CreateUsagePlanKey where
toQuery :: CreateUsagePlanKey -> QueryString
toQuery = QueryString -> CreateUsagePlanKey -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty