{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MarketplaceMetering.MeterUsage
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- API to emit metering records. For identical requests, the API is
-- idempotent. It simply returns the metering record ID.
--
-- MeterUsage is authenticated on the buyer\'s AWS account using
-- credentials from the EC2 instance, ECS task, or EKS pod.
--
-- MeterUsage can optionally include multiple usage allocations, to provide
-- customers with usage data split into buckets by tags that you define (or
-- allow the customer to define).
module Amazonka.MarketplaceMetering.MeterUsage
  ( -- * Creating a Request
    MeterUsage (..),
    newMeterUsage,

    -- * Request Lenses
    meterUsage_usageQuantity,
    meterUsage_usageAllocations,
    meterUsage_dryRun,
    meterUsage_productCode,
    meterUsage_timestamp,
    meterUsage_usageDimension,

    -- * Destructuring the Response
    MeterUsageResponse (..),
    newMeterUsageResponse,

    -- * Response Lenses
    meterUsageResponse_meteringRecordId,
    meterUsageResponse_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

-- | /See:/ 'newMeterUsage' smart constructor.
data MeterUsage = MeterUsage'
  { -- | Consumption value for the hour. Defaults to @0@ if not specified.
    MeterUsage -> Maybe Natural
usageQuantity :: Prelude.Maybe Prelude.Natural,
    -- | The set of UsageAllocations to submit.
    --
    -- The sum of all UsageAllocation quantities must equal the UsageQuantity
    -- of the MeterUsage request, and each UsageAllocation must have a unique
    -- set of tags (include no tags).
    MeterUsage -> Maybe (NonEmpty UsageAllocation)
usageAllocations :: Prelude.Maybe (Prelude.NonEmpty UsageAllocation),
    -- | Checks whether you have the permissions required for the action, but
    -- does not make the request. If you have the permissions, the request
    -- returns DryRunOperation; otherwise, it returns UnauthorizedException.
    -- Defaults to @false@ if not specified.
    MeterUsage -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | Product code is used to uniquely identify a product in AWS Marketplace.
    -- The product code should be the same as the one used during the
    -- publishing of a new product.
    MeterUsage -> Text
productCode :: Prelude.Text,
    -- | Timestamp, in UTC, for which the usage is being reported. Your
    -- application can meter usage for up to one hour in the past. Make sure
    -- the timestamp value is not before the start of the software usage.
    MeterUsage -> POSIX
timestamp :: Core.POSIX,
    -- | It will be one of the fcp dimension name provided during the publishing
    -- of the product.
    MeterUsage -> Text
usageDimension :: Prelude.Text
  }
  deriving (MeterUsage -> MeterUsage -> Bool
(MeterUsage -> MeterUsage -> Bool)
-> (MeterUsage -> MeterUsage -> Bool) -> Eq MeterUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MeterUsage -> MeterUsage -> Bool
$c/= :: MeterUsage -> MeterUsage -> Bool
== :: MeterUsage -> MeterUsage -> Bool
$c== :: MeterUsage -> MeterUsage -> Bool
Prelude.Eq, ReadPrec [MeterUsage]
ReadPrec MeterUsage
Int -> ReadS MeterUsage
ReadS [MeterUsage]
(Int -> ReadS MeterUsage)
-> ReadS [MeterUsage]
-> ReadPrec MeterUsage
-> ReadPrec [MeterUsage]
-> Read MeterUsage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MeterUsage]
$creadListPrec :: ReadPrec [MeterUsage]
readPrec :: ReadPrec MeterUsage
$creadPrec :: ReadPrec MeterUsage
readList :: ReadS [MeterUsage]
$creadList :: ReadS [MeterUsage]
readsPrec :: Int -> ReadS MeterUsage
$creadsPrec :: Int -> ReadS MeterUsage
Prelude.Read, Int -> MeterUsage -> ShowS
[MeterUsage] -> ShowS
MeterUsage -> String
(Int -> MeterUsage -> ShowS)
-> (MeterUsage -> String)
-> ([MeterUsage] -> ShowS)
-> Show MeterUsage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MeterUsage] -> ShowS
$cshowList :: [MeterUsage] -> ShowS
show :: MeterUsage -> String
$cshow :: MeterUsage -> String
showsPrec :: Int -> MeterUsage -> ShowS
$cshowsPrec :: Int -> MeterUsage -> ShowS
Prelude.Show, (forall x. MeterUsage -> Rep MeterUsage x)
-> (forall x. Rep MeterUsage x -> MeterUsage) -> Generic MeterUsage
forall x. Rep MeterUsage x -> MeterUsage
forall x. MeterUsage -> Rep MeterUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MeterUsage x -> MeterUsage
$cfrom :: forall x. MeterUsage -> Rep MeterUsage x
Prelude.Generic)

-- |
-- Create a value of 'MeterUsage' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'usageQuantity', 'meterUsage_usageQuantity' - Consumption value for the hour. Defaults to @0@ if not specified.
--
-- 'usageAllocations', 'meterUsage_usageAllocations' - The set of UsageAllocations to submit.
--
-- The sum of all UsageAllocation quantities must equal the UsageQuantity
-- of the MeterUsage request, and each UsageAllocation must have a unique
-- set of tags (include no tags).
--
-- 'dryRun', 'meterUsage_dryRun' - Checks whether you have the permissions required for the action, but
-- does not make the request. If you have the permissions, the request
-- returns DryRunOperation; otherwise, it returns UnauthorizedException.
-- Defaults to @false@ if not specified.
--
-- 'productCode', 'meterUsage_productCode' - Product code is used to uniquely identify a product in AWS Marketplace.
-- The product code should be the same as the one used during the
-- publishing of a new product.
--
-- 'timestamp', 'meterUsage_timestamp' - Timestamp, in UTC, for which the usage is being reported. Your
-- application can meter usage for up to one hour in the past. Make sure
-- the timestamp value is not before the start of the software usage.
--
-- 'usageDimension', 'meterUsage_usageDimension' - It will be one of the fcp dimension name provided during the publishing
-- of the product.
newMeterUsage ::
  -- | 'productCode'
  Prelude.Text ->
  -- | 'timestamp'
  Prelude.UTCTime ->
  -- | 'usageDimension'
  Prelude.Text ->
  MeterUsage
newMeterUsage :: Text -> UTCTime -> Text -> MeterUsage
newMeterUsage
  Text
pProductCode_
  UTCTime
pTimestamp_
  Text
pUsageDimension_ =
    MeterUsage' :: Maybe Natural
-> Maybe (NonEmpty UsageAllocation)
-> Maybe Bool
-> Text
-> POSIX
-> Text
-> MeterUsage
MeterUsage'
      { $sel:usageQuantity:MeterUsage' :: Maybe Natural
usageQuantity = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:usageAllocations:MeterUsage' :: Maybe (NonEmpty UsageAllocation)
usageAllocations = Maybe (NonEmpty UsageAllocation)
forall a. Maybe a
Prelude.Nothing,
        $sel:dryRun:MeterUsage' :: Maybe Bool
dryRun = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:productCode:MeterUsage' :: Text
productCode = Text
pProductCode_,
        $sel:timestamp:MeterUsage' :: POSIX
timestamp = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pTimestamp_,
        $sel:usageDimension:MeterUsage' :: Text
usageDimension = Text
pUsageDimension_
      }

-- | Consumption value for the hour. Defaults to @0@ if not specified.
meterUsage_usageQuantity :: Lens.Lens' MeterUsage (Prelude.Maybe Prelude.Natural)
meterUsage_usageQuantity :: (Maybe Natural -> f (Maybe Natural)) -> MeterUsage -> f MeterUsage
meterUsage_usageQuantity = (MeterUsage -> Maybe Natural)
-> (MeterUsage -> Maybe Natural -> MeterUsage)
-> Lens MeterUsage MeterUsage (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeterUsage' {Maybe Natural
usageQuantity :: Maybe Natural
$sel:usageQuantity:MeterUsage' :: MeterUsage -> Maybe Natural
usageQuantity} -> Maybe Natural
usageQuantity) (\s :: MeterUsage
s@MeterUsage' {} Maybe Natural
a -> MeterUsage
s {$sel:usageQuantity:MeterUsage' :: Maybe Natural
usageQuantity = Maybe Natural
a} :: MeterUsage)

-- | The set of UsageAllocations to submit.
--
-- The sum of all UsageAllocation quantities must equal the UsageQuantity
-- of the MeterUsage request, and each UsageAllocation must have a unique
-- set of tags (include no tags).
meterUsage_usageAllocations :: Lens.Lens' MeterUsage (Prelude.Maybe (Prelude.NonEmpty UsageAllocation))
meterUsage_usageAllocations :: (Maybe (NonEmpty UsageAllocation)
 -> f (Maybe (NonEmpty UsageAllocation)))
-> MeterUsage -> f MeterUsage
meterUsage_usageAllocations = (MeterUsage -> Maybe (NonEmpty UsageAllocation))
-> (MeterUsage -> Maybe (NonEmpty UsageAllocation) -> MeterUsage)
-> Lens
     MeterUsage
     MeterUsage
     (Maybe (NonEmpty UsageAllocation))
     (Maybe (NonEmpty UsageAllocation))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeterUsage' {Maybe (NonEmpty UsageAllocation)
usageAllocations :: Maybe (NonEmpty UsageAllocation)
$sel:usageAllocations:MeterUsage' :: MeterUsage -> Maybe (NonEmpty UsageAllocation)
usageAllocations} -> Maybe (NonEmpty UsageAllocation)
usageAllocations) (\s :: MeterUsage
s@MeterUsage' {} Maybe (NonEmpty UsageAllocation)
a -> MeterUsage
s {$sel:usageAllocations:MeterUsage' :: Maybe (NonEmpty UsageAllocation)
usageAllocations = Maybe (NonEmpty UsageAllocation)
a} :: MeterUsage) ((Maybe (NonEmpty UsageAllocation)
  -> f (Maybe (NonEmpty UsageAllocation)))
 -> MeterUsage -> f MeterUsage)
-> ((Maybe (NonEmpty UsageAllocation)
     -> f (Maybe (NonEmpty UsageAllocation)))
    -> Maybe (NonEmpty UsageAllocation)
    -> f (Maybe (NonEmpty UsageAllocation)))
-> (Maybe (NonEmpty UsageAllocation)
    -> f (Maybe (NonEmpty UsageAllocation)))
-> MeterUsage
-> f MeterUsage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty UsageAllocation)
  (NonEmpty UsageAllocation)
  (NonEmpty UsageAllocation)
  (NonEmpty UsageAllocation)
-> Iso
     (Maybe (NonEmpty UsageAllocation))
     (Maybe (NonEmpty UsageAllocation))
     (Maybe (NonEmpty UsageAllocation))
     (Maybe (NonEmpty UsageAllocation))
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
  (NonEmpty UsageAllocation)
  (NonEmpty UsageAllocation)
  (NonEmpty UsageAllocation)
  (NonEmpty UsageAllocation)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Checks whether you have the permissions required for the action, but
-- does not make the request. If you have the permissions, the request
-- returns DryRunOperation; otherwise, it returns UnauthorizedException.
-- Defaults to @false@ if not specified.
meterUsage_dryRun :: Lens.Lens' MeterUsage (Prelude.Maybe Prelude.Bool)
meterUsage_dryRun :: (Maybe Bool -> f (Maybe Bool)) -> MeterUsage -> f MeterUsage
meterUsage_dryRun = (MeterUsage -> Maybe Bool)
-> (MeterUsage -> Maybe Bool -> MeterUsage)
-> Lens MeterUsage MeterUsage (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeterUsage' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:MeterUsage' :: MeterUsage -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: MeterUsage
s@MeterUsage' {} Maybe Bool
a -> MeterUsage
s {$sel:dryRun:MeterUsage' :: Maybe Bool
dryRun = Maybe Bool
a} :: MeterUsage)

-- | Product code is used to uniquely identify a product in AWS Marketplace.
-- The product code should be the same as the one used during the
-- publishing of a new product.
meterUsage_productCode :: Lens.Lens' MeterUsage Prelude.Text
meterUsage_productCode :: (Text -> f Text) -> MeterUsage -> f MeterUsage
meterUsage_productCode = (MeterUsage -> Text)
-> (MeterUsage -> Text -> MeterUsage)
-> Lens MeterUsage MeterUsage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeterUsage' {Text
productCode :: Text
$sel:productCode:MeterUsage' :: MeterUsage -> Text
productCode} -> Text
productCode) (\s :: MeterUsage
s@MeterUsage' {} Text
a -> MeterUsage
s {$sel:productCode:MeterUsage' :: Text
productCode = Text
a} :: MeterUsage)

-- | Timestamp, in UTC, for which the usage is being reported. Your
-- application can meter usage for up to one hour in the past. Make sure
-- the timestamp value is not before the start of the software usage.
meterUsage_timestamp :: Lens.Lens' MeterUsage Prelude.UTCTime
meterUsage_timestamp :: (UTCTime -> f UTCTime) -> MeterUsage -> f MeterUsage
meterUsage_timestamp = (MeterUsage -> POSIX)
-> (MeterUsage -> POSIX -> MeterUsage)
-> Lens MeterUsage MeterUsage POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeterUsage' {POSIX
timestamp :: POSIX
$sel:timestamp:MeterUsage' :: MeterUsage -> POSIX
timestamp} -> POSIX
timestamp) (\s :: MeterUsage
s@MeterUsage' {} POSIX
a -> MeterUsage
s {$sel:timestamp:MeterUsage' :: POSIX
timestamp = POSIX
a} :: MeterUsage) ((POSIX -> f POSIX) -> MeterUsage -> f MeterUsage)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> MeterUsage
-> f MeterUsage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | It will be one of the fcp dimension name provided during the publishing
-- of the product.
meterUsage_usageDimension :: Lens.Lens' MeterUsage Prelude.Text
meterUsage_usageDimension :: (Text -> f Text) -> MeterUsage -> f MeterUsage
meterUsage_usageDimension = (MeterUsage -> Text)
-> (MeterUsage -> Text -> MeterUsage)
-> Lens MeterUsage MeterUsage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeterUsage' {Text
usageDimension :: Text
$sel:usageDimension:MeterUsage' :: MeterUsage -> Text
usageDimension} -> Text
usageDimension) (\s :: MeterUsage
s@MeterUsage' {} Text
a -> MeterUsage
s {$sel:usageDimension:MeterUsage' :: Text
usageDimension = Text
a} :: MeterUsage)

instance Core.AWSRequest MeterUsage where
  type AWSResponse MeterUsage = MeterUsageResponse
  request :: MeterUsage -> Request MeterUsage
request = Service -> MeterUsage -> Request MeterUsage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy MeterUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse MeterUsage)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse MeterUsage))
-> Logger
-> Service
-> Proxy MeterUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse MeterUsage)))
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 -> Int -> MeterUsageResponse
MeterUsageResponse'
            (Maybe Text -> Int -> MeterUsageResponse)
-> Either String (Maybe Text)
-> Either String (Int -> MeterUsageResponse)
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
"MeteringRecordId")
            Either String (Int -> MeterUsageResponse)
-> Either String Int -> Either String MeterUsageResponse
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 MeterUsage

instance Prelude.NFData MeterUsage

instance Core.ToHeaders MeterUsage where
  toHeaders :: MeterUsage -> ResponseHeaders
toHeaders =
    ResponseHeaders -> MeterUsage -> 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.MeterUsage" ::
                          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 MeterUsage where
  toJSON :: MeterUsage -> Value
toJSON MeterUsage' {Maybe Bool
Maybe Natural
Maybe (NonEmpty UsageAllocation)
Text
POSIX
usageDimension :: Text
timestamp :: POSIX
productCode :: Text
dryRun :: Maybe Bool
usageAllocations :: Maybe (NonEmpty UsageAllocation)
usageQuantity :: Maybe Natural
$sel:usageDimension:MeterUsage' :: MeterUsage -> Text
$sel:timestamp:MeterUsage' :: MeterUsage -> POSIX
$sel:productCode:MeterUsage' :: MeterUsage -> Text
$sel:dryRun:MeterUsage' :: MeterUsage -> Maybe Bool
$sel:usageAllocations:MeterUsage' :: MeterUsage -> Maybe (NonEmpty UsageAllocation)
$sel:usageQuantity:MeterUsage' :: MeterUsage -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"UsageQuantity" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
usageQuantity,
            (Text
"UsageAllocations" Text -> NonEmpty UsageAllocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty UsageAllocation -> Pair)
-> Maybe (NonEmpty UsageAllocation) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty UsageAllocation)
usageAllocations,
            (Text
"DryRun" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
dryRun,
            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
"Timestamp" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
timestamp),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"UsageDimension" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
usageDimension)
          ]
      )

instance Core.ToPath MeterUsage where
  toPath :: MeterUsage -> ByteString
toPath = ByteString -> MeterUsage -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery MeterUsage where
  toQuery :: MeterUsage -> QueryString
toQuery = QueryString -> MeterUsage -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newMeterUsageResponse' smart constructor.
data MeterUsageResponse = MeterUsageResponse'
  { -- | Metering record id.
    MeterUsageResponse -> Maybe Text
meteringRecordId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    MeterUsageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (MeterUsageResponse -> MeterUsageResponse -> Bool
(MeterUsageResponse -> MeterUsageResponse -> Bool)
-> (MeterUsageResponse -> MeterUsageResponse -> Bool)
-> Eq MeterUsageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MeterUsageResponse -> MeterUsageResponse -> Bool
$c/= :: MeterUsageResponse -> MeterUsageResponse -> Bool
== :: MeterUsageResponse -> MeterUsageResponse -> Bool
$c== :: MeterUsageResponse -> MeterUsageResponse -> Bool
Prelude.Eq, ReadPrec [MeterUsageResponse]
ReadPrec MeterUsageResponse
Int -> ReadS MeterUsageResponse
ReadS [MeterUsageResponse]
(Int -> ReadS MeterUsageResponse)
-> ReadS [MeterUsageResponse]
-> ReadPrec MeterUsageResponse
-> ReadPrec [MeterUsageResponse]
-> Read MeterUsageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MeterUsageResponse]
$creadListPrec :: ReadPrec [MeterUsageResponse]
readPrec :: ReadPrec MeterUsageResponse
$creadPrec :: ReadPrec MeterUsageResponse
readList :: ReadS [MeterUsageResponse]
$creadList :: ReadS [MeterUsageResponse]
readsPrec :: Int -> ReadS MeterUsageResponse
$creadsPrec :: Int -> ReadS MeterUsageResponse
Prelude.Read, Int -> MeterUsageResponse -> ShowS
[MeterUsageResponse] -> ShowS
MeterUsageResponse -> String
(Int -> MeterUsageResponse -> ShowS)
-> (MeterUsageResponse -> String)
-> ([MeterUsageResponse] -> ShowS)
-> Show MeterUsageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MeterUsageResponse] -> ShowS
$cshowList :: [MeterUsageResponse] -> ShowS
show :: MeterUsageResponse -> String
$cshow :: MeterUsageResponse -> String
showsPrec :: Int -> MeterUsageResponse -> ShowS
$cshowsPrec :: Int -> MeterUsageResponse -> ShowS
Prelude.Show, (forall x. MeterUsageResponse -> Rep MeterUsageResponse x)
-> (forall x. Rep MeterUsageResponse x -> MeterUsageResponse)
-> Generic MeterUsageResponse
forall x. Rep MeterUsageResponse x -> MeterUsageResponse
forall x. MeterUsageResponse -> Rep MeterUsageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MeterUsageResponse x -> MeterUsageResponse
$cfrom :: forall x. MeterUsageResponse -> Rep MeterUsageResponse x
Prelude.Generic)

-- |
-- Create a value of 'MeterUsageResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'meteringRecordId', 'meterUsageResponse_meteringRecordId' - Metering record id.
--
-- 'httpStatus', 'meterUsageResponse_httpStatus' - The response's http status code.
newMeterUsageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  MeterUsageResponse
newMeterUsageResponse :: Int -> MeterUsageResponse
newMeterUsageResponse Int
pHttpStatus_ =
  MeterUsageResponse' :: Maybe Text -> Int -> MeterUsageResponse
MeterUsageResponse'
    { $sel:meteringRecordId:MeterUsageResponse' :: Maybe Text
meteringRecordId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:MeterUsageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Metering record id.
meterUsageResponse_meteringRecordId :: Lens.Lens' MeterUsageResponse (Prelude.Maybe Prelude.Text)
meterUsageResponse_meteringRecordId :: (Maybe Text -> f (Maybe Text))
-> MeterUsageResponse -> f MeterUsageResponse
meterUsageResponse_meteringRecordId = (MeterUsageResponse -> Maybe Text)
-> (MeterUsageResponse -> Maybe Text -> MeterUsageResponse)
-> Lens
     MeterUsageResponse MeterUsageResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeterUsageResponse' {Maybe Text
meteringRecordId :: Maybe Text
$sel:meteringRecordId:MeterUsageResponse' :: MeterUsageResponse -> Maybe Text
meteringRecordId} -> Maybe Text
meteringRecordId) (\s :: MeterUsageResponse
s@MeterUsageResponse' {} Maybe Text
a -> MeterUsageResponse
s {$sel:meteringRecordId:MeterUsageResponse' :: Maybe Text
meteringRecordId = Maybe Text
a} :: MeterUsageResponse)

-- | The response's http status code.
meterUsageResponse_httpStatus :: Lens.Lens' MeterUsageResponse Prelude.Int
meterUsageResponse_httpStatus :: (Int -> f Int) -> MeterUsageResponse -> f MeterUsageResponse
meterUsageResponse_httpStatus = (MeterUsageResponse -> Int)
-> (MeterUsageResponse -> Int -> MeterUsageResponse)
-> Lens MeterUsageResponse MeterUsageResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeterUsageResponse' {Int
httpStatus :: Int
$sel:httpStatus:MeterUsageResponse' :: MeterUsageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: MeterUsageResponse
s@MeterUsageResponse' {} Int
a -> MeterUsageResponse
s {$sel:httpStatus:MeterUsageResponse' :: Int
httpStatus = Int
a} :: MeterUsageResponse)

instance Prelude.NFData MeterUsageResponse