{-# 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_signature,
registerUsageResponse_publicKeyRotationTimestamp,
registerUsageResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(RegisterUsage -> RegisterUsage -> Bool)
-> (RegisterUsage -> RegisterUsage -> Bool) -> Eq RegisterUsage
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]
(Int -> ReadS RegisterUsage)
-> ReadS [RegisterUsage]
-> ReadPrec RegisterUsage
-> ReadPrec [RegisterUsage]
-> Read 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
(Int -> RegisterUsage -> ShowS)
-> (RegisterUsage -> String)
-> ([RegisterUsage] -> ShowS)
-> Show RegisterUsage
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. RegisterUsage -> Rep RegisterUsage x)
-> (forall x. Rep RegisterUsage x -> RegisterUsage)
-> Generic RegisterUsage
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' :: Maybe Text -> Text -> Natural -> RegisterUsage
RegisterUsage'
{ $sel:nonce:RegisterUsage' :: Maybe Text
nonce = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> RegisterUsage -> f RegisterUsage
registerUsage_nonce = (RegisterUsage -> Maybe Text)
-> (RegisterUsage -> Maybe Text -> RegisterUsage)
-> Lens RegisterUsage RegisterUsage (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> RegisterUsage -> f RegisterUsage
registerUsage_productCode = (RegisterUsage -> Text)
-> (RegisterUsage -> Text -> RegisterUsage)
-> Lens RegisterUsage RegisterUsage Text Text
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 :: (Natural -> f Natural) -> RegisterUsage -> f RegisterUsage
registerUsage_publicKeyVersion = (RegisterUsage -> Natural)
-> (RegisterUsage -> Natural -> RegisterUsage)
-> Lens RegisterUsage RegisterUsage Natural Natural
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 :: RegisterUsage -> Request RegisterUsage
request = Service -> RegisterUsage -> Request RegisterUsage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy RegisterUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RegisterUsage)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse RegisterUsage))
-> Logger
-> Service
-> Proxy RegisterUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RegisterUsage)))
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 ->
Maybe Text -> Maybe POSIX -> Int -> RegisterUsageResponse
RegisterUsageResponse'
(Maybe Text -> Maybe POSIX -> Int -> RegisterUsageResponse)
-> Either String (Maybe Text)
-> Either String (Maybe POSIX -> Int -> RegisterUsageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Signature")
Either String (Maybe POSIX -> Int -> RegisterUsageResponse)
-> Either String (Maybe POSIX)
-> Either String (Int -> RegisterUsageResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PublicKeyRotationTimestamp")
Either String (Int -> RegisterUsageResponse)
-> Either String Int -> Either String RegisterUsageResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable RegisterUsage
instance Prelude.NFData RegisterUsage
instance Core.ToHeaders RegisterUsage where
toHeaders :: RegisterUsage -> ResponseHeaders
toHeaders =
ResponseHeaders -> RegisterUsage -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSMPMeteringService.RegisterUsage" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.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
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Nonce" 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
nonce,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ProductCode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
productCode),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"PublicKeyVersion" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
publicKeyVersion)
]
)
instance Core.ToPath RegisterUsage where
toPath :: RegisterUsage -> ByteString
toPath = ByteString -> RegisterUsage -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery RegisterUsage where
toQuery :: RegisterUsage -> QueryString
toQuery = QueryString -> RegisterUsage -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data RegisterUsageResponse = RegisterUsageResponse'
{
RegisterUsageResponse -> Maybe Text
signature :: Prelude.Maybe Prelude.Text,
RegisterUsageResponse -> Maybe POSIX
publicKeyRotationTimestamp :: Prelude.Maybe Core.POSIX,
RegisterUsageResponse -> Int
httpStatus :: Prelude.Int
}
deriving (RegisterUsageResponse -> RegisterUsageResponse -> Bool
(RegisterUsageResponse -> RegisterUsageResponse -> Bool)
-> (RegisterUsageResponse -> RegisterUsageResponse -> Bool)
-> Eq RegisterUsageResponse
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]
(Int -> ReadS RegisterUsageResponse)
-> ReadS [RegisterUsageResponse]
-> ReadPrec RegisterUsageResponse
-> ReadPrec [RegisterUsageResponse]
-> Read 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
(Int -> RegisterUsageResponse -> ShowS)
-> (RegisterUsageResponse -> String)
-> ([RegisterUsageResponse] -> ShowS)
-> Show RegisterUsageResponse
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. RegisterUsageResponse -> Rep RegisterUsageResponse x)
-> (forall x. Rep RegisterUsageResponse x -> RegisterUsageResponse)
-> Generic RegisterUsageResponse
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' :: Maybe Text -> Maybe POSIX -> Int -> RegisterUsageResponse
RegisterUsageResponse'
{ $sel:signature:RegisterUsageResponse' :: Maybe Text
signature = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:publicKeyRotationTimestamp:RegisterUsageResponse' :: Maybe POSIX
publicKeyRotationTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:RegisterUsageResponse' :: Int
httpStatus = Int
pHttpStatus_
}
registerUsageResponse_signature :: Lens.Lens' RegisterUsageResponse (Prelude.Maybe Prelude.Text)
registerUsageResponse_signature :: (Maybe Text -> f (Maybe Text))
-> RegisterUsageResponse -> f RegisterUsageResponse
registerUsageResponse_signature = (RegisterUsageResponse -> Maybe Text)
-> (RegisterUsageResponse -> Maybe Text -> RegisterUsageResponse)
-> Lens
RegisterUsageResponse
RegisterUsageResponse
(Maybe Text)
(Maybe Text)
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_publicKeyRotationTimestamp :: Lens.Lens' RegisterUsageResponse (Prelude.Maybe Prelude.UTCTime)
registerUsageResponse_publicKeyRotationTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> RegisterUsageResponse -> f RegisterUsageResponse
registerUsageResponse_publicKeyRotationTimestamp = (RegisterUsageResponse -> Maybe POSIX)
-> (RegisterUsageResponse -> Maybe POSIX -> RegisterUsageResponse)
-> Lens
RegisterUsageResponse
RegisterUsageResponse
(Maybe POSIX)
(Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
-> RegisterUsageResponse -> f RegisterUsageResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
-> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> RegisterUsageResponse
-> f RegisterUsageResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time
registerUsageResponse_httpStatus :: Lens.Lens' RegisterUsageResponse Prelude.Int
registerUsageResponse_httpStatus :: (Int -> f Int) -> RegisterUsageResponse -> f RegisterUsageResponse
registerUsageResponse_httpStatus = (RegisterUsageResponse -> Int)
-> (RegisterUsageResponse -> Int -> RegisterUsageResponse)
-> Lens RegisterUsageResponse RegisterUsageResponse Int Int
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