{-# 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.BatchMeterUsage
-- 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)
--
-- BatchMeterUsage is called from a SaaS application listed on the AWS
-- Marketplace to post metering records for a set of customers.
--
-- For identical requests, the API is idempotent; requests can be retried
-- with the same records or a subset of the input records.
--
-- Every request to BatchMeterUsage is for one product. If you need to
-- meter usage for multiple products, you must make multiple calls to
-- BatchMeterUsage.
--
-- BatchMeterUsage can process up to 25 UsageRecords at a time.
--
-- A UsageRecord can optionally include multiple usage allocations, to
-- provide customers with usagedata split into buckets by tags that you
-- define (or allow the customer to define).
--
-- BatchMeterUsage requests must be less than 1MB in size.
module Amazonka.MarketplaceMetering.BatchMeterUsage
  ( -- * Creating a Request
    BatchMeterUsage (..),
    newBatchMeterUsage,

    -- * Request Lenses
    batchMeterUsage_usageRecords,
    batchMeterUsage_productCode,

    -- * Destructuring the Response
    BatchMeterUsageResponse (..),
    newBatchMeterUsageResponse,

    -- * Response Lenses
    batchMeterUsageResponse_results,
    batchMeterUsageResponse_unprocessedRecords,
    batchMeterUsageResponse_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

-- | A BatchMeterUsageRequest contains UsageRecords, which indicate
-- quantities of usage within your application.
--
-- /See:/ 'newBatchMeterUsage' smart constructor.
data BatchMeterUsage = BatchMeterUsage'
  { -- | The set of UsageRecords to submit. BatchMeterUsage accepts up to 25
    -- UsageRecords at a time.
    BatchMeterUsage -> [UsageRecord]
usageRecords :: [UsageRecord],
    -- | 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.
    BatchMeterUsage -> Text
productCode :: Prelude.Text
  }
  deriving (BatchMeterUsage -> BatchMeterUsage -> Bool
(BatchMeterUsage -> BatchMeterUsage -> Bool)
-> (BatchMeterUsage -> BatchMeterUsage -> Bool)
-> Eq BatchMeterUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchMeterUsage -> BatchMeterUsage -> Bool
$c/= :: BatchMeterUsage -> BatchMeterUsage -> Bool
== :: BatchMeterUsage -> BatchMeterUsage -> Bool
$c== :: BatchMeterUsage -> BatchMeterUsage -> Bool
Prelude.Eq, ReadPrec [BatchMeterUsage]
ReadPrec BatchMeterUsage
Int -> ReadS BatchMeterUsage
ReadS [BatchMeterUsage]
(Int -> ReadS BatchMeterUsage)
-> ReadS [BatchMeterUsage]
-> ReadPrec BatchMeterUsage
-> ReadPrec [BatchMeterUsage]
-> Read BatchMeterUsage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchMeterUsage]
$creadListPrec :: ReadPrec [BatchMeterUsage]
readPrec :: ReadPrec BatchMeterUsage
$creadPrec :: ReadPrec BatchMeterUsage
readList :: ReadS [BatchMeterUsage]
$creadList :: ReadS [BatchMeterUsage]
readsPrec :: Int -> ReadS BatchMeterUsage
$creadsPrec :: Int -> ReadS BatchMeterUsage
Prelude.Read, Int -> BatchMeterUsage -> ShowS
[BatchMeterUsage] -> ShowS
BatchMeterUsage -> String
(Int -> BatchMeterUsage -> ShowS)
-> (BatchMeterUsage -> String)
-> ([BatchMeterUsage] -> ShowS)
-> Show BatchMeterUsage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchMeterUsage] -> ShowS
$cshowList :: [BatchMeterUsage] -> ShowS
show :: BatchMeterUsage -> String
$cshow :: BatchMeterUsage -> String
showsPrec :: Int -> BatchMeterUsage -> ShowS
$cshowsPrec :: Int -> BatchMeterUsage -> ShowS
Prelude.Show, (forall x. BatchMeterUsage -> Rep BatchMeterUsage x)
-> (forall x. Rep BatchMeterUsage x -> BatchMeterUsage)
-> Generic BatchMeterUsage
forall x. Rep BatchMeterUsage x -> BatchMeterUsage
forall x. BatchMeterUsage -> Rep BatchMeterUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchMeterUsage x -> BatchMeterUsage
$cfrom :: forall x. BatchMeterUsage -> Rep BatchMeterUsage x
Prelude.Generic)

-- |
-- Create a value of 'BatchMeterUsage' 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:
--
-- 'usageRecords', 'batchMeterUsage_usageRecords' - The set of UsageRecords to submit. BatchMeterUsage accepts up to 25
-- UsageRecords at a time.
--
-- 'productCode', 'batchMeterUsage_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.
newBatchMeterUsage ::
  -- | 'productCode'
  Prelude.Text ->
  BatchMeterUsage
newBatchMeterUsage :: Text -> BatchMeterUsage
newBatchMeterUsage Text
pProductCode_ =
  BatchMeterUsage' :: [UsageRecord] -> Text -> BatchMeterUsage
BatchMeterUsage'
    { $sel:usageRecords:BatchMeterUsage' :: [UsageRecord]
usageRecords = [UsageRecord]
forall a. Monoid a => a
Prelude.mempty,
      $sel:productCode:BatchMeterUsage' :: Text
productCode = Text
pProductCode_
    }

-- | The set of UsageRecords to submit. BatchMeterUsage accepts up to 25
-- UsageRecords at a time.
batchMeterUsage_usageRecords :: Lens.Lens' BatchMeterUsage [UsageRecord]
batchMeterUsage_usageRecords :: ([UsageRecord] -> f [UsageRecord])
-> BatchMeterUsage -> f BatchMeterUsage
batchMeterUsage_usageRecords = (BatchMeterUsage -> [UsageRecord])
-> (BatchMeterUsage -> [UsageRecord] -> BatchMeterUsage)
-> Lens BatchMeterUsage BatchMeterUsage [UsageRecord] [UsageRecord]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchMeterUsage' {[UsageRecord]
usageRecords :: [UsageRecord]
$sel:usageRecords:BatchMeterUsage' :: BatchMeterUsage -> [UsageRecord]
usageRecords} -> [UsageRecord]
usageRecords) (\s :: BatchMeterUsage
s@BatchMeterUsage' {} [UsageRecord]
a -> BatchMeterUsage
s {$sel:usageRecords:BatchMeterUsage' :: [UsageRecord]
usageRecords = [UsageRecord]
a} :: BatchMeterUsage) (([UsageRecord] -> f [UsageRecord])
 -> BatchMeterUsage -> f BatchMeterUsage)
-> (([UsageRecord] -> f [UsageRecord])
    -> [UsageRecord] -> f [UsageRecord])
-> ([UsageRecord] -> f [UsageRecord])
-> BatchMeterUsage
-> f BatchMeterUsage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UsageRecord] -> f [UsageRecord])
-> [UsageRecord] -> f [UsageRecord]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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.
batchMeterUsage_productCode :: Lens.Lens' BatchMeterUsage Prelude.Text
batchMeterUsage_productCode :: (Text -> f Text) -> BatchMeterUsage -> f BatchMeterUsage
batchMeterUsage_productCode = (BatchMeterUsage -> Text)
-> (BatchMeterUsage -> Text -> BatchMeterUsage)
-> Lens BatchMeterUsage BatchMeterUsage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchMeterUsage' {Text
productCode :: Text
$sel:productCode:BatchMeterUsage' :: BatchMeterUsage -> Text
productCode} -> Text
productCode) (\s :: BatchMeterUsage
s@BatchMeterUsage' {} Text
a -> BatchMeterUsage
s {$sel:productCode:BatchMeterUsage' :: Text
productCode = Text
a} :: BatchMeterUsage)

instance Core.AWSRequest BatchMeterUsage where
  type
    AWSResponse BatchMeterUsage =
      BatchMeterUsageResponse
  request :: BatchMeterUsage -> Request BatchMeterUsage
request = Service -> BatchMeterUsage -> Request BatchMeterUsage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchMeterUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchMeterUsage)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchMeterUsage))
-> Logger
-> Service
-> Proxy BatchMeterUsage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchMeterUsage)))
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 [UsageRecordResult]
-> Maybe [UsageRecord] -> Int -> BatchMeterUsageResponse
BatchMeterUsageResponse'
            (Maybe [UsageRecordResult]
 -> Maybe [UsageRecord] -> Int -> BatchMeterUsageResponse)
-> Either String (Maybe [UsageRecordResult])
-> Either
     String (Maybe [UsageRecord] -> Int -> BatchMeterUsageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [UsageRecordResult]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Results" Either String (Maybe (Maybe [UsageRecordResult]))
-> Maybe [UsageRecordResult]
-> Either String (Maybe [UsageRecordResult])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [UsageRecordResult]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String (Maybe [UsageRecord] -> Int -> BatchMeterUsageResponse)
-> Either String (Maybe [UsageRecord])
-> Either String (Int -> BatchMeterUsageResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [UsageRecord]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"UnprocessedRecords"
                            Either String (Maybe (Maybe [UsageRecord]))
-> Maybe [UsageRecord] -> Either String (Maybe [UsageRecord])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [UsageRecord]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> BatchMeterUsageResponse)
-> Either String Int -> Either String BatchMeterUsageResponse
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 BatchMeterUsage

instance Prelude.NFData BatchMeterUsage

instance Core.ToHeaders BatchMeterUsage where
  toHeaders :: BatchMeterUsage -> ResponseHeaders
toHeaders =
    ResponseHeaders -> BatchMeterUsage -> 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.BatchMeterUsage" ::
                          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 BatchMeterUsage where
  toJSON :: BatchMeterUsage -> Value
toJSON BatchMeterUsage' {[UsageRecord]
Text
productCode :: Text
usageRecords :: [UsageRecord]
$sel:productCode:BatchMeterUsage' :: BatchMeterUsage -> Text
$sel:usageRecords:BatchMeterUsage' :: BatchMeterUsage -> [UsageRecord]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UsageRecords" Text -> [UsageRecord] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [UsageRecord]
usageRecords),
            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)
          ]
      )

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

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

-- | Contains the UsageRecords processed by BatchMeterUsage and any records
-- that have failed due to transient error.
--
-- /See:/ 'newBatchMeterUsageResponse' smart constructor.
data BatchMeterUsageResponse = BatchMeterUsageResponse'
  { -- | Contains all UsageRecords processed by BatchMeterUsage. These records
    -- were either honored by AWS Marketplace Metering Service or were invalid.
    BatchMeterUsageResponse -> Maybe [UsageRecordResult]
results :: Prelude.Maybe [UsageRecordResult],
    -- | Contains all UsageRecords that were not processed by BatchMeterUsage.
    -- This is a list of UsageRecords. You can retry the failed request by
    -- making another BatchMeterUsage call with this list as input in the
    -- BatchMeterUsageRequest.
    BatchMeterUsageResponse -> Maybe [UsageRecord]
unprocessedRecords :: Prelude.Maybe [UsageRecord],
    -- | The response's http status code.
    BatchMeterUsageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchMeterUsageResponse -> BatchMeterUsageResponse -> Bool
(BatchMeterUsageResponse -> BatchMeterUsageResponse -> Bool)
-> (BatchMeterUsageResponse -> BatchMeterUsageResponse -> Bool)
-> Eq BatchMeterUsageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchMeterUsageResponse -> BatchMeterUsageResponse -> Bool
$c/= :: BatchMeterUsageResponse -> BatchMeterUsageResponse -> Bool
== :: BatchMeterUsageResponse -> BatchMeterUsageResponse -> Bool
$c== :: BatchMeterUsageResponse -> BatchMeterUsageResponse -> Bool
Prelude.Eq, ReadPrec [BatchMeterUsageResponse]
ReadPrec BatchMeterUsageResponse
Int -> ReadS BatchMeterUsageResponse
ReadS [BatchMeterUsageResponse]
(Int -> ReadS BatchMeterUsageResponse)
-> ReadS [BatchMeterUsageResponse]
-> ReadPrec BatchMeterUsageResponse
-> ReadPrec [BatchMeterUsageResponse]
-> Read BatchMeterUsageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchMeterUsageResponse]
$creadListPrec :: ReadPrec [BatchMeterUsageResponse]
readPrec :: ReadPrec BatchMeterUsageResponse
$creadPrec :: ReadPrec BatchMeterUsageResponse
readList :: ReadS [BatchMeterUsageResponse]
$creadList :: ReadS [BatchMeterUsageResponse]
readsPrec :: Int -> ReadS BatchMeterUsageResponse
$creadsPrec :: Int -> ReadS BatchMeterUsageResponse
Prelude.Read, Int -> BatchMeterUsageResponse -> ShowS
[BatchMeterUsageResponse] -> ShowS
BatchMeterUsageResponse -> String
(Int -> BatchMeterUsageResponse -> ShowS)
-> (BatchMeterUsageResponse -> String)
-> ([BatchMeterUsageResponse] -> ShowS)
-> Show BatchMeterUsageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchMeterUsageResponse] -> ShowS
$cshowList :: [BatchMeterUsageResponse] -> ShowS
show :: BatchMeterUsageResponse -> String
$cshow :: BatchMeterUsageResponse -> String
showsPrec :: Int -> BatchMeterUsageResponse -> ShowS
$cshowsPrec :: Int -> BatchMeterUsageResponse -> ShowS
Prelude.Show, (forall x.
 BatchMeterUsageResponse -> Rep BatchMeterUsageResponse x)
-> (forall x.
    Rep BatchMeterUsageResponse x -> BatchMeterUsageResponse)
-> Generic BatchMeterUsageResponse
forall x. Rep BatchMeterUsageResponse x -> BatchMeterUsageResponse
forall x. BatchMeterUsageResponse -> Rep BatchMeterUsageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchMeterUsageResponse x -> BatchMeterUsageResponse
$cfrom :: forall x. BatchMeterUsageResponse -> Rep BatchMeterUsageResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchMeterUsageResponse' 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:
--
-- 'results', 'batchMeterUsageResponse_results' - Contains all UsageRecords processed by BatchMeterUsage. These records
-- were either honored by AWS Marketplace Metering Service or were invalid.
--
-- 'unprocessedRecords', 'batchMeterUsageResponse_unprocessedRecords' - Contains all UsageRecords that were not processed by BatchMeterUsage.
-- This is a list of UsageRecords. You can retry the failed request by
-- making another BatchMeterUsage call with this list as input in the
-- BatchMeterUsageRequest.
--
-- 'httpStatus', 'batchMeterUsageResponse_httpStatus' - The response's http status code.
newBatchMeterUsageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchMeterUsageResponse
newBatchMeterUsageResponse :: Int -> BatchMeterUsageResponse
newBatchMeterUsageResponse Int
pHttpStatus_ =
  BatchMeterUsageResponse' :: Maybe [UsageRecordResult]
-> Maybe [UsageRecord] -> Int -> BatchMeterUsageResponse
BatchMeterUsageResponse'
    { $sel:results:BatchMeterUsageResponse' :: Maybe [UsageRecordResult]
results = Maybe [UsageRecordResult]
forall a. Maybe a
Prelude.Nothing,
      $sel:unprocessedRecords:BatchMeterUsageResponse' :: Maybe [UsageRecord]
unprocessedRecords = Maybe [UsageRecord]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchMeterUsageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Contains all UsageRecords processed by BatchMeterUsage. These records
-- were either honored by AWS Marketplace Metering Service or were invalid.
batchMeterUsageResponse_results :: Lens.Lens' BatchMeterUsageResponse (Prelude.Maybe [UsageRecordResult])
batchMeterUsageResponse_results :: (Maybe [UsageRecordResult] -> f (Maybe [UsageRecordResult]))
-> BatchMeterUsageResponse -> f BatchMeterUsageResponse
batchMeterUsageResponse_results = (BatchMeterUsageResponse -> Maybe [UsageRecordResult])
-> (BatchMeterUsageResponse
    -> Maybe [UsageRecordResult] -> BatchMeterUsageResponse)
-> Lens
     BatchMeterUsageResponse
     BatchMeterUsageResponse
     (Maybe [UsageRecordResult])
     (Maybe [UsageRecordResult])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchMeterUsageResponse' {Maybe [UsageRecordResult]
results :: Maybe [UsageRecordResult]
$sel:results:BatchMeterUsageResponse' :: BatchMeterUsageResponse -> Maybe [UsageRecordResult]
results} -> Maybe [UsageRecordResult]
results) (\s :: BatchMeterUsageResponse
s@BatchMeterUsageResponse' {} Maybe [UsageRecordResult]
a -> BatchMeterUsageResponse
s {$sel:results:BatchMeterUsageResponse' :: Maybe [UsageRecordResult]
results = Maybe [UsageRecordResult]
a} :: BatchMeterUsageResponse) ((Maybe [UsageRecordResult] -> f (Maybe [UsageRecordResult]))
 -> BatchMeterUsageResponse -> f BatchMeterUsageResponse)
-> ((Maybe [UsageRecordResult] -> f (Maybe [UsageRecordResult]))
    -> Maybe [UsageRecordResult] -> f (Maybe [UsageRecordResult]))
-> (Maybe [UsageRecordResult] -> f (Maybe [UsageRecordResult]))
-> BatchMeterUsageResponse
-> f BatchMeterUsageResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [UsageRecordResult]
  [UsageRecordResult]
  [UsageRecordResult]
  [UsageRecordResult]
-> Iso
     (Maybe [UsageRecordResult])
     (Maybe [UsageRecordResult])
     (Maybe [UsageRecordResult])
     (Maybe [UsageRecordResult])
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
  [UsageRecordResult]
  [UsageRecordResult]
  [UsageRecordResult]
  [UsageRecordResult]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Contains all UsageRecords that were not processed by BatchMeterUsage.
-- This is a list of UsageRecords. You can retry the failed request by
-- making another BatchMeterUsage call with this list as input in the
-- BatchMeterUsageRequest.
batchMeterUsageResponse_unprocessedRecords :: Lens.Lens' BatchMeterUsageResponse (Prelude.Maybe [UsageRecord])
batchMeterUsageResponse_unprocessedRecords :: (Maybe [UsageRecord] -> f (Maybe [UsageRecord]))
-> BatchMeterUsageResponse -> f BatchMeterUsageResponse
batchMeterUsageResponse_unprocessedRecords = (BatchMeterUsageResponse -> Maybe [UsageRecord])
-> (BatchMeterUsageResponse
    -> Maybe [UsageRecord] -> BatchMeterUsageResponse)
-> Lens
     BatchMeterUsageResponse
     BatchMeterUsageResponse
     (Maybe [UsageRecord])
     (Maybe [UsageRecord])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchMeterUsageResponse' {Maybe [UsageRecord]
unprocessedRecords :: Maybe [UsageRecord]
$sel:unprocessedRecords:BatchMeterUsageResponse' :: BatchMeterUsageResponse -> Maybe [UsageRecord]
unprocessedRecords} -> Maybe [UsageRecord]
unprocessedRecords) (\s :: BatchMeterUsageResponse
s@BatchMeterUsageResponse' {} Maybe [UsageRecord]
a -> BatchMeterUsageResponse
s {$sel:unprocessedRecords:BatchMeterUsageResponse' :: Maybe [UsageRecord]
unprocessedRecords = Maybe [UsageRecord]
a} :: BatchMeterUsageResponse) ((Maybe [UsageRecord] -> f (Maybe [UsageRecord]))
 -> BatchMeterUsageResponse -> f BatchMeterUsageResponse)
-> ((Maybe [UsageRecord] -> f (Maybe [UsageRecord]))
    -> Maybe [UsageRecord] -> f (Maybe [UsageRecord]))
-> (Maybe [UsageRecord] -> f (Maybe [UsageRecord]))
-> BatchMeterUsageResponse
-> f BatchMeterUsageResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [UsageRecord] [UsageRecord] [UsageRecord] [UsageRecord]
-> Iso
     (Maybe [UsageRecord])
     (Maybe [UsageRecord])
     (Maybe [UsageRecord])
     (Maybe [UsageRecord])
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 [UsageRecord] [UsageRecord] [UsageRecord] [UsageRecord]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchMeterUsageResponse