{-# 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.UpdateUsage
(
UpdateUsage (..),
newUpdateUsage,
updateUsage_patchOperations,
updateUsage_usagePlanId,
updateUsage_keyId,
Usage (..),
newUsage,
usage_endDate,
usage_items,
usage_position,
usage_startDate,
usage_usagePlanId,
)
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 UpdateUsage = UpdateUsage'
{
UpdateUsage -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
UpdateUsage -> Text
usagePlanId :: Prelude.Text,
UpdateUsage -> Text
keyId :: Prelude.Text
}
deriving (UpdateUsage -> UpdateUsage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUsage -> UpdateUsage -> Bool
$c/= :: UpdateUsage -> UpdateUsage -> Bool
== :: UpdateUsage -> UpdateUsage -> Bool
$c== :: UpdateUsage -> UpdateUsage -> Bool
Prelude.Eq, ReadPrec [UpdateUsage]
ReadPrec UpdateUsage
Int -> ReadS UpdateUsage
ReadS [UpdateUsage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateUsage]
$creadListPrec :: ReadPrec [UpdateUsage]
readPrec :: ReadPrec UpdateUsage
$creadPrec :: ReadPrec UpdateUsage
readList :: ReadS [UpdateUsage]
$creadList :: ReadS [UpdateUsage]
readsPrec :: Int -> ReadS UpdateUsage
$creadsPrec :: Int -> ReadS UpdateUsage
Prelude.Read, Int -> UpdateUsage -> ShowS
[UpdateUsage] -> ShowS
UpdateUsage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUsage] -> ShowS
$cshowList :: [UpdateUsage] -> ShowS
show :: UpdateUsage -> String
$cshow :: UpdateUsage -> String
showsPrec :: Int -> UpdateUsage -> ShowS
$cshowsPrec :: Int -> UpdateUsage -> ShowS
Prelude.Show, forall x. Rep UpdateUsage x -> UpdateUsage
forall x. UpdateUsage -> Rep UpdateUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateUsage x -> UpdateUsage
$cfrom :: forall x. UpdateUsage -> Rep UpdateUsage x
Prelude.Generic)
newUpdateUsage ::
Prelude.Text ->
Prelude.Text ->
UpdateUsage
newUpdateUsage :: Text -> Text -> UpdateUsage
newUpdateUsage Text
pUsagePlanId_ Text
pKeyId_ =
UpdateUsage'
{ $sel:patchOperations:UpdateUsage' :: Maybe [PatchOperation]
patchOperations = forall a. Maybe a
Prelude.Nothing,
$sel:usagePlanId:UpdateUsage' :: Text
usagePlanId = Text
pUsagePlanId_,
$sel:keyId:UpdateUsage' :: Text
keyId = Text
pKeyId_
}
updateUsage_patchOperations :: Lens.Lens' UpdateUsage (Prelude.Maybe [PatchOperation])
updateUsage_patchOperations :: Lens' UpdateUsage (Maybe [PatchOperation])
updateUsage_patchOperations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUsage' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateUsage' :: UpdateUsage -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateUsage
s@UpdateUsage' {} Maybe [PatchOperation]
a -> UpdateUsage
s {$sel:patchOperations:UpdateUsage' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateUsage) 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
updateUsage_usagePlanId :: Lens.Lens' UpdateUsage Prelude.Text
updateUsage_usagePlanId :: Lens' UpdateUsage Text
updateUsage_usagePlanId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUsage' {Text
usagePlanId :: Text
$sel:usagePlanId:UpdateUsage' :: UpdateUsage -> Text
usagePlanId} -> Text
usagePlanId) (\s :: UpdateUsage
s@UpdateUsage' {} Text
a -> UpdateUsage
s {$sel:usagePlanId:UpdateUsage' :: Text
usagePlanId = Text
a} :: UpdateUsage)
updateUsage_keyId :: Lens.Lens' UpdateUsage Prelude.Text
updateUsage_keyId :: Lens' UpdateUsage Text
updateUsage_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUsage' {Text
keyId :: Text
$sel:keyId:UpdateUsage' :: UpdateUsage -> Text
keyId} -> Text
keyId) (\s :: UpdateUsage
s@UpdateUsage' {} Text
a -> UpdateUsage
s {$sel:keyId:UpdateUsage' :: Text
keyId = Text
a} :: UpdateUsage)
instance Core.AWSRequest UpdateUsage where
type AWSResponse UpdateUsage = Usage
request :: (Service -> Service) -> UpdateUsage -> Request UpdateUsage
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateUsage)))
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 UpdateUsage where
hashWithSalt :: Int -> UpdateUsage -> Int
hashWithSalt Int
_salt UpdateUsage' {Maybe [PatchOperation]
Text
keyId :: Text
usagePlanId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:keyId:UpdateUsage' :: UpdateUsage -> Text
$sel:usagePlanId:UpdateUsage' :: UpdateUsage -> Text
$sel:patchOperations:UpdateUsage' :: UpdateUsage -> Maybe [PatchOperation]
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PatchOperation]
patchOperations
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
usagePlanId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
keyId
instance Prelude.NFData UpdateUsage where
rnf :: UpdateUsage -> ()
rnf UpdateUsage' {Maybe [PatchOperation]
Text
keyId :: Text
usagePlanId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:keyId:UpdateUsage' :: UpdateUsage -> Text
$sel:usagePlanId:UpdateUsage' :: UpdateUsage -> Text
$sel:patchOperations:UpdateUsage' :: UpdateUsage -> Maybe [PatchOperation]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [PatchOperation]
patchOperations
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
usagePlanId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
keyId
instance Data.ToHeaders UpdateUsage where
toHeaders :: UpdateUsage -> 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 UpdateUsage where
toJSON :: UpdateUsage -> Value
toJSON UpdateUsage' {Maybe [PatchOperation]
Text
keyId :: Text
usagePlanId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:keyId:UpdateUsage' :: UpdateUsage -> Text
$sel:usagePlanId:UpdateUsage' :: UpdateUsage -> Text
$sel:patchOperations:UpdateUsage' :: UpdateUsage -> Maybe [PatchOperation]
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"patchOperations" 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 [PatchOperation]
patchOperations
]
)
instance Data.ToPath UpdateUsage where
toPath :: UpdateUsage -> ByteString
toPath UpdateUsage' {Maybe [PatchOperation]
Text
keyId :: Text
usagePlanId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:keyId:UpdateUsage' :: UpdateUsage -> Text
$sel:usagePlanId:UpdateUsage' :: UpdateUsage -> Text
$sel:patchOperations:UpdateUsage' :: UpdateUsage -> Maybe [PatchOperation]
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/usageplans/",
forall a. ToByteString a => a -> ByteString
Data.toBS Text
usagePlanId,
ByteString
"/keys/",
forall a. ToByteString a => a -> ByteString
Data.toBS Text
keyId,
ByteString
"/usage"
]
instance Data.ToQuery UpdateUsage where
toQuery :: UpdateUsage -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty