{-# 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.MarketplaceMetering.RegisterUsage
(
RegisterUsage (..),
newRegisterUsage,
registerUsage_nonce,
registerUsage_productCode,
registerUsage_publicKeyVersion,
RegisterUsageResponse (..),
newRegisterUsageResponse,
registerUsageResponse_publicKeyRotationTimestamp,
registerUsageResponse_signature,
registerUsageResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MarketplaceMetering.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data RegisterUsage = RegisterUsage'
{
RegisterUsage -> Maybe Text
nonce :: Prelude.Maybe Prelude.Text,
RegisterUsage -> Text
productCode :: Prelude.Text,
RegisterUsage -> Natural
publicKeyVersion :: Prelude.Natural
}
deriving (RegisterUsage -> RegisterUsage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterUsage -> RegisterUsage -> Bool
$c/= :: RegisterUsage -> RegisterUsage -> Bool
== :: RegisterUsage -> RegisterUsage -> Bool
$c== :: RegisterUsage -> RegisterUsage -> Bool
Prelude.Eq, ReadPrec [RegisterUsage]
ReadPrec RegisterUsage
Int -> ReadS RegisterUsage
ReadS [RegisterUsage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterUsage]
$creadListPrec :: ReadPrec [RegisterUsage]
readPrec :: ReadPrec RegisterUsage
$creadPrec :: ReadPrec RegisterUsage
readList :: ReadS [RegisterUsage]
$creadList :: ReadS [RegisterUsage]
readsPrec :: Int -> ReadS RegisterUsage
$creadsPrec :: Int -> ReadS RegisterUsage
Prelude.Read, Int -> RegisterUsage -> ShowS
[RegisterUsage] -> ShowS
RegisterUsage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterUsage] -> ShowS
$cshowList :: [RegisterUsage] -> ShowS
show :: RegisterUsage -> String
$cshow :: RegisterUsage -> String
showsPrec :: Int -> RegisterUsage -> ShowS
$cshowsPrec :: Int -> RegisterUsage -> ShowS
Prelude.Show, forall x. Rep RegisterUsage x -> RegisterUsage
forall x. RegisterUsage -> Rep RegisterUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegisterUsage x -> RegisterUsage
$cfrom :: forall x. RegisterUsage -> Rep RegisterUsage x
Prelude.Generic)
newRegisterUsage ::
Prelude.Text ->
Prelude.Natural ->
RegisterUsage
newRegisterUsage :: Text -> Natural -> RegisterUsage
newRegisterUsage Text
pProductCode_ Natural
pPublicKeyVersion_ =
RegisterUsage'
{ $sel:nonce:RegisterUsage' :: Maybe Text
nonce = forall a. Maybe a
Prelude.Nothing,
$sel:productCode:RegisterUsage' :: Text
productCode = Text
pProductCode_,
$sel:publicKeyVersion:RegisterUsage' :: Natural
publicKeyVersion = Natural
pPublicKeyVersion_
}
registerUsage_nonce :: Lens.Lens' RegisterUsage (Prelude.Maybe Prelude.Text)
registerUsage_nonce :: Lens' RegisterUsage (Maybe Text)
registerUsage_nonce = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterUsage' {Maybe Text
nonce :: Maybe Text
$sel:nonce:RegisterUsage' :: RegisterUsage -> Maybe Text
nonce} -> Maybe Text
nonce) (\s :: RegisterUsage
s@RegisterUsage' {} Maybe Text
a -> RegisterUsage
s {$sel:nonce:RegisterUsage' :: Maybe Text
nonce = Maybe Text
a} :: RegisterUsage)
registerUsage_productCode :: Lens.Lens' RegisterUsage Prelude.Text
registerUsage_productCode :: Lens' RegisterUsage Text
registerUsage_productCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterUsage' {Text
productCode :: Text
$sel:productCode:RegisterUsage' :: RegisterUsage -> Text
productCode} -> Text
productCode) (\s :: RegisterUsage
s@RegisterUsage' {} Text
a -> RegisterUsage
s {$sel:productCode:RegisterUsage' :: Text
productCode = Text
a} :: RegisterUsage)
registerUsage_publicKeyVersion :: Lens.Lens' RegisterUsage Prelude.Natural
registerUsage_publicKeyVersion :: Lens' RegisterUsage Natural
registerUsage_publicKeyVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterUsage' {Natural
publicKeyVersion :: Natural
$sel:publicKeyVersion:RegisterUsage' :: RegisterUsage -> Natural
publicKeyVersion} -> Natural
publicKeyVersion) (\s :: RegisterUsage
s@RegisterUsage' {} Natural
a -> RegisterUsage
s {$sel:publicKeyVersion:RegisterUsage' :: Natural
publicKeyVersion = Natural
a} :: RegisterUsage)
instance Core.AWSRequest RegisterUsage where
type
AWSResponse RegisterUsage =
RegisterUsageResponse
request :: (Service -> Service) -> RegisterUsage -> Request RegisterUsage
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 RegisterUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RegisterUsage)))
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 ->
Maybe POSIX -> Maybe Text -> Int -> RegisterUsageResponse
RegisterUsageResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"PublicKeyRotationTimestamp")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Signature")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable RegisterUsage where
hashWithSalt :: Int -> RegisterUsage -> Int
hashWithSalt Int
_salt RegisterUsage' {Natural
Maybe Text
Text
publicKeyVersion :: Natural
productCode :: Text
nonce :: Maybe Text
$sel:publicKeyVersion:RegisterUsage' :: RegisterUsage -> Natural
$sel:productCode:RegisterUsage' :: RegisterUsage -> Text
$sel:nonce:RegisterUsage' :: RegisterUsage -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nonce
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
productCode
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
publicKeyVersion
instance Prelude.NFData RegisterUsage where
rnf :: RegisterUsage -> ()
rnf RegisterUsage' {Natural
Maybe Text
Text
publicKeyVersion :: Natural
productCode :: Text
nonce :: Maybe Text
$sel:publicKeyVersion:RegisterUsage' :: RegisterUsage -> Natural
$sel:productCode:RegisterUsage' :: RegisterUsage -> Text
$sel:nonce:RegisterUsage' :: RegisterUsage -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nonce
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
productCode
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
publicKeyVersion
instance Data.ToHeaders RegisterUsage where
toHeaders :: RegisterUsage -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSMPMeteringService.RegisterUsage" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON RegisterUsage where
toJSON :: RegisterUsage -> Value
toJSON RegisterUsage' {Natural
Maybe Text
Text
publicKeyVersion :: Natural
productCode :: Text
nonce :: Maybe Text
$sel:publicKeyVersion:RegisterUsage' :: RegisterUsage -> Natural
$sel:productCode:RegisterUsage' :: RegisterUsage -> Text
$sel:nonce:RegisterUsage' :: RegisterUsage -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Nonce" 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
nonce,
forall a. a -> Maybe a
Prelude.Just (Key
"ProductCode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
productCode),
forall a. a -> Maybe a
Prelude.Just
(Key
"PublicKeyVersion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
publicKeyVersion)
]
)
instance Data.ToPath RegisterUsage where
toPath :: RegisterUsage -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery RegisterUsage where
toQuery :: RegisterUsage -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data RegisterUsageResponse = RegisterUsageResponse'
{
RegisterUsageResponse -> Maybe POSIX
publicKeyRotationTimestamp :: Prelude.Maybe Data.POSIX,
RegisterUsageResponse -> Maybe Text
signature :: Prelude.Maybe Prelude.Text,
RegisterUsageResponse -> Int
httpStatus :: Prelude.Int
}
deriving (RegisterUsageResponse -> RegisterUsageResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterUsageResponse -> RegisterUsageResponse -> Bool
$c/= :: RegisterUsageResponse -> RegisterUsageResponse -> Bool
== :: RegisterUsageResponse -> RegisterUsageResponse -> Bool
$c== :: RegisterUsageResponse -> RegisterUsageResponse -> Bool
Prelude.Eq, ReadPrec [RegisterUsageResponse]
ReadPrec RegisterUsageResponse
Int -> ReadS RegisterUsageResponse
ReadS [RegisterUsageResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterUsageResponse]
$creadListPrec :: ReadPrec [RegisterUsageResponse]
readPrec :: ReadPrec RegisterUsageResponse
$creadPrec :: ReadPrec RegisterUsageResponse
readList :: ReadS [RegisterUsageResponse]
$creadList :: ReadS [RegisterUsageResponse]
readsPrec :: Int -> ReadS RegisterUsageResponse
$creadsPrec :: Int -> ReadS RegisterUsageResponse
Prelude.Read, Int -> RegisterUsageResponse -> ShowS
[RegisterUsageResponse] -> ShowS
RegisterUsageResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterUsageResponse] -> ShowS
$cshowList :: [RegisterUsageResponse] -> ShowS
show :: RegisterUsageResponse -> String
$cshow :: RegisterUsageResponse -> String
showsPrec :: Int -> RegisterUsageResponse -> ShowS
$cshowsPrec :: Int -> RegisterUsageResponse -> ShowS
Prelude.Show, forall x. Rep RegisterUsageResponse x -> RegisterUsageResponse
forall x. RegisterUsageResponse -> Rep RegisterUsageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RegisterUsageResponse x -> RegisterUsageResponse
$cfrom :: forall x. RegisterUsageResponse -> Rep RegisterUsageResponse x
Prelude.Generic)
newRegisterUsageResponse ::
Prelude.Int ->
RegisterUsageResponse
newRegisterUsageResponse :: Int -> RegisterUsageResponse
newRegisterUsageResponse Int
pHttpStatus_ =
RegisterUsageResponse'
{ $sel:publicKeyRotationTimestamp:RegisterUsageResponse' :: Maybe POSIX
publicKeyRotationTimestamp =
forall a. Maybe a
Prelude.Nothing,
$sel:signature:RegisterUsageResponse' :: Maybe Text
signature = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:RegisterUsageResponse' :: Int
httpStatus = Int
pHttpStatus_
}
registerUsageResponse_publicKeyRotationTimestamp :: Lens.Lens' RegisterUsageResponse (Prelude.Maybe Prelude.UTCTime)
registerUsageResponse_publicKeyRotationTimestamp :: Lens' RegisterUsageResponse (Maybe UTCTime)
registerUsageResponse_publicKeyRotationTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterUsageResponse' {Maybe POSIX
publicKeyRotationTimestamp :: Maybe POSIX
$sel:publicKeyRotationTimestamp:RegisterUsageResponse' :: RegisterUsageResponse -> Maybe POSIX
publicKeyRotationTimestamp} -> Maybe POSIX
publicKeyRotationTimestamp) (\s :: RegisterUsageResponse
s@RegisterUsageResponse' {} Maybe POSIX
a -> RegisterUsageResponse
s {$sel:publicKeyRotationTimestamp:RegisterUsageResponse' :: Maybe POSIX
publicKeyRotationTimestamp = Maybe POSIX
a} :: RegisterUsageResponse) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time
registerUsageResponse_signature :: Lens.Lens' RegisterUsageResponse (Prelude.Maybe Prelude.Text)
registerUsageResponse_signature :: Lens' RegisterUsageResponse (Maybe Text)
registerUsageResponse_signature = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterUsageResponse' {Maybe Text
signature :: Maybe Text
$sel:signature:RegisterUsageResponse' :: RegisterUsageResponse -> Maybe Text
signature} -> Maybe Text
signature) (\s :: RegisterUsageResponse
s@RegisterUsageResponse' {} Maybe Text
a -> RegisterUsageResponse
s {$sel:signature:RegisterUsageResponse' :: Maybe Text
signature = Maybe Text
a} :: RegisterUsageResponse)
registerUsageResponse_httpStatus :: Lens.Lens' RegisterUsageResponse Prelude.Int
registerUsageResponse_httpStatus :: Lens' RegisterUsageResponse Int
registerUsageResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterUsageResponse' {Int
httpStatus :: Int
$sel:httpStatus:RegisterUsageResponse' :: RegisterUsageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: RegisterUsageResponse
s@RegisterUsageResponse' {} Int
a -> RegisterUsageResponse
s {$sel:httpStatus:RegisterUsageResponse' :: Int
httpStatus = Int
a} :: RegisterUsageResponse)
instance Prelude.NFData RegisterUsageResponse where
rnf :: RegisterUsageResponse -> ()
rnf RegisterUsageResponse' {Int
Maybe Text
Maybe POSIX
httpStatus :: Int
signature :: Maybe Text
publicKeyRotationTimestamp :: Maybe POSIX
$sel:httpStatus:RegisterUsageResponse' :: RegisterUsageResponse -> Int
$sel:signature:RegisterUsageResponse' :: RegisterUsageResponse -> Maybe Text
$sel:publicKeyRotationTimestamp:RegisterUsageResponse' :: RegisterUsageResponse -> Maybe POSIX
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
publicKeyRotationTimestamp
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
signature
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus