{-# 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.UpdateUsagePlan
(
UpdateUsagePlan (..),
newUpdateUsagePlan,
updateUsagePlan_patchOperations,
updateUsagePlan_usagePlanId,
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 UpdateUsagePlan = UpdateUsagePlan'
{
UpdateUsagePlan -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
UpdateUsagePlan -> Text
usagePlanId :: Prelude.Text
}
deriving (UpdateUsagePlan -> UpdateUsagePlan -> Bool
(UpdateUsagePlan -> UpdateUsagePlan -> Bool)
-> (UpdateUsagePlan -> UpdateUsagePlan -> Bool)
-> Eq UpdateUsagePlan
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUsagePlan -> UpdateUsagePlan -> Bool
$c/= :: UpdateUsagePlan -> UpdateUsagePlan -> Bool
== :: UpdateUsagePlan -> UpdateUsagePlan -> Bool
$c== :: UpdateUsagePlan -> UpdateUsagePlan -> Bool
Prelude.Eq, ReadPrec [UpdateUsagePlan]
ReadPrec UpdateUsagePlan
Int -> ReadS UpdateUsagePlan
ReadS [UpdateUsagePlan]
(Int -> ReadS UpdateUsagePlan)
-> ReadS [UpdateUsagePlan]
-> ReadPrec UpdateUsagePlan
-> ReadPrec [UpdateUsagePlan]
-> Read UpdateUsagePlan
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateUsagePlan]
$creadListPrec :: ReadPrec [UpdateUsagePlan]
readPrec :: ReadPrec UpdateUsagePlan
$creadPrec :: ReadPrec UpdateUsagePlan
readList :: ReadS [UpdateUsagePlan]
$creadList :: ReadS [UpdateUsagePlan]
readsPrec :: Int -> ReadS UpdateUsagePlan
$creadsPrec :: Int -> ReadS UpdateUsagePlan
Prelude.Read, Int -> UpdateUsagePlan -> ShowS
[UpdateUsagePlan] -> ShowS
UpdateUsagePlan -> String
(Int -> UpdateUsagePlan -> ShowS)
-> (UpdateUsagePlan -> String)
-> ([UpdateUsagePlan] -> ShowS)
-> Show UpdateUsagePlan
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUsagePlan] -> ShowS
$cshowList :: [UpdateUsagePlan] -> ShowS
show :: UpdateUsagePlan -> String
$cshow :: UpdateUsagePlan -> String
showsPrec :: Int -> UpdateUsagePlan -> ShowS
$cshowsPrec :: Int -> UpdateUsagePlan -> ShowS
Prelude.Show, (forall x. UpdateUsagePlan -> Rep UpdateUsagePlan x)
-> (forall x. Rep UpdateUsagePlan x -> UpdateUsagePlan)
-> Generic UpdateUsagePlan
forall x. Rep UpdateUsagePlan x -> UpdateUsagePlan
forall x. UpdateUsagePlan -> Rep UpdateUsagePlan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateUsagePlan x -> UpdateUsagePlan
$cfrom :: forall x. UpdateUsagePlan -> Rep UpdateUsagePlan x
Prelude.Generic)
newUpdateUsagePlan ::
Prelude.Text ->
UpdateUsagePlan
newUpdateUsagePlan :: Text -> UpdateUsagePlan
newUpdateUsagePlan Text
pUsagePlanId_ =
UpdateUsagePlan' :: Maybe [PatchOperation] -> Text -> UpdateUsagePlan
UpdateUsagePlan'
{ $sel:patchOperations:UpdateUsagePlan' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
forall a. Maybe a
Prelude.Nothing,
$sel:usagePlanId:UpdateUsagePlan' :: Text
usagePlanId = Text
pUsagePlanId_
}
updateUsagePlan_patchOperations :: Lens.Lens' UpdateUsagePlan (Prelude.Maybe [PatchOperation])
updateUsagePlan_patchOperations :: (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateUsagePlan -> f UpdateUsagePlan
updateUsagePlan_patchOperations = (UpdateUsagePlan -> Maybe [PatchOperation])
-> (UpdateUsagePlan -> Maybe [PatchOperation] -> UpdateUsagePlan)
-> Lens
UpdateUsagePlan
UpdateUsagePlan
(Maybe [PatchOperation])
(Maybe [PatchOperation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUsagePlan' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateUsagePlan' :: UpdateUsagePlan -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateUsagePlan
s@UpdateUsagePlan' {} Maybe [PatchOperation]
a -> UpdateUsagePlan
s {$sel:patchOperations:UpdateUsagePlan' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateUsagePlan) ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateUsagePlan -> f UpdateUsagePlan)
-> ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateUsagePlan
-> f UpdateUsagePlan
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
-> Iso
(Maybe [PatchOperation])
(Maybe [PatchOperation])
(Maybe [PatchOperation])
(Maybe [PatchOperation])
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
[PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
updateUsagePlan_usagePlanId :: Lens.Lens' UpdateUsagePlan Prelude.Text
updateUsagePlan_usagePlanId :: (Text -> f Text) -> UpdateUsagePlan -> f UpdateUsagePlan
updateUsagePlan_usagePlanId = (UpdateUsagePlan -> Text)
-> (UpdateUsagePlan -> Text -> UpdateUsagePlan)
-> Lens UpdateUsagePlan UpdateUsagePlan Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUsagePlan' {Text
usagePlanId :: Text
$sel:usagePlanId:UpdateUsagePlan' :: UpdateUsagePlan -> Text
usagePlanId} -> Text
usagePlanId) (\s :: UpdateUsagePlan
s@UpdateUsagePlan' {} Text
a -> UpdateUsagePlan
s {$sel:usagePlanId:UpdateUsagePlan' :: Text
usagePlanId = Text
a} :: UpdateUsagePlan)
instance Core.AWSRequest UpdateUsagePlan where
type AWSResponse UpdateUsagePlan = UsagePlan
request :: UpdateUsagePlan -> Request UpdateUsagePlan
request = Service -> UpdateUsagePlan -> Request UpdateUsagePlan
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdateUsagePlan
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateUsagePlan)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdateUsagePlan))
-> Logger
-> Service
-> Proxy UpdateUsagePlan
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateUsagePlan)))
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 UpdateUsagePlan
instance Prelude.NFData UpdateUsagePlan
instance Core.ToHeaders UpdateUsagePlan where
toHeaders :: UpdateUsagePlan -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdateUsagePlan -> 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 UpdateUsagePlan where
toJSON :: UpdateUsagePlan -> Value
toJSON UpdateUsagePlan' {Maybe [PatchOperation]
Text
usagePlanId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:usagePlanId:UpdateUsagePlan' :: UpdateUsagePlan -> Text
$sel:patchOperations:UpdateUsagePlan' :: UpdateUsagePlan -> Maybe [PatchOperation]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"patchOperations" Text -> [PatchOperation] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
([PatchOperation] -> Pair) -> Maybe [PatchOperation] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PatchOperation]
patchOperations
]
)
instance Core.ToPath UpdateUsagePlan where
toPath :: UpdateUsagePlan -> ByteString
toPath UpdateUsagePlan' {Maybe [PatchOperation]
Text
usagePlanId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:usagePlanId:UpdateUsagePlan' :: UpdateUsagePlan -> Text
$sel:patchOperations:UpdateUsagePlan' :: UpdateUsagePlan -> Maybe [PatchOperation]
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/usageplans/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
usagePlanId]
instance Core.ToQuery UpdateUsagePlan where
toQuery :: UpdateUsagePlan -> QueryString
toQuery = QueryString -> UpdateUsagePlan -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty