{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.MarketplaceMetering.Types.UsageRecord 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.UsageAllocation
import qualified Amazonka.Prelude as Prelude
data UsageRecord = UsageRecord'
{
UsageRecord -> Maybe Natural
quantity :: Prelude.Maybe Prelude.Natural,
UsageRecord -> Maybe (NonEmpty UsageAllocation)
usageAllocations :: Prelude.Maybe (Prelude.NonEmpty UsageAllocation),
UsageRecord -> POSIX
timestamp :: Data.POSIX,
UsageRecord -> Text
customerIdentifier :: Prelude.Text,
UsageRecord -> Text
dimension :: Prelude.Text
}
deriving (UsageRecord -> UsageRecord -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsageRecord -> UsageRecord -> Bool
$c/= :: UsageRecord -> UsageRecord -> Bool
== :: UsageRecord -> UsageRecord -> Bool
$c== :: UsageRecord -> UsageRecord -> Bool
Prelude.Eq, ReadPrec [UsageRecord]
ReadPrec UsageRecord
Int -> ReadS UsageRecord
ReadS [UsageRecord]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsageRecord]
$creadListPrec :: ReadPrec [UsageRecord]
readPrec :: ReadPrec UsageRecord
$creadPrec :: ReadPrec UsageRecord
readList :: ReadS [UsageRecord]
$creadList :: ReadS [UsageRecord]
readsPrec :: Int -> ReadS UsageRecord
$creadsPrec :: Int -> ReadS UsageRecord
Prelude.Read, Int -> UsageRecord -> ShowS
[UsageRecord] -> ShowS
UsageRecord -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsageRecord] -> ShowS
$cshowList :: [UsageRecord] -> ShowS
show :: UsageRecord -> String
$cshow :: UsageRecord -> String
showsPrec :: Int -> UsageRecord -> ShowS
$cshowsPrec :: Int -> UsageRecord -> ShowS
Prelude.Show, forall x. Rep UsageRecord x -> UsageRecord
forall x. UsageRecord -> Rep UsageRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsageRecord x -> UsageRecord
$cfrom :: forall x. UsageRecord -> Rep UsageRecord x
Prelude.Generic)
newUsageRecord ::
Prelude.UTCTime ->
Prelude.Text ->
Prelude.Text ->
UsageRecord
newUsageRecord :: UTCTime -> Text -> Text -> UsageRecord
newUsageRecord
UTCTime
pTimestamp_
Text
pCustomerIdentifier_
Text
pDimension_ =
UsageRecord'
{ $sel:quantity:UsageRecord' :: Maybe Natural
quantity = forall a. Maybe a
Prelude.Nothing,
$sel:usageAllocations:UsageRecord' :: Maybe (NonEmpty UsageAllocation)
usageAllocations = forall a. Maybe a
Prelude.Nothing,
$sel:timestamp:UsageRecord' :: POSIX
timestamp = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pTimestamp_,
$sel:customerIdentifier:UsageRecord' :: Text
customerIdentifier = Text
pCustomerIdentifier_,
$sel:dimension:UsageRecord' :: Text
dimension = Text
pDimension_
}
usageRecord_quantity :: Lens.Lens' UsageRecord (Prelude.Maybe Prelude.Natural)
usageRecord_quantity :: Lens' UsageRecord (Maybe Natural)
usageRecord_quantity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageRecord' {Maybe Natural
quantity :: Maybe Natural
$sel:quantity:UsageRecord' :: UsageRecord -> Maybe Natural
quantity} -> Maybe Natural
quantity) (\s :: UsageRecord
s@UsageRecord' {} Maybe Natural
a -> UsageRecord
s {$sel:quantity:UsageRecord' :: Maybe Natural
quantity = Maybe Natural
a} :: UsageRecord)
usageRecord_usageAllocations :: Lens.Lens' UsageRecord (Prelude.Maybe (Prelude.NonEmpty UsageAllocation))
usageRecord_usageAllocations :: Lens' UsageRecord (Maybe (NonEmpty UsageAllocation))
usageRecord_usageAllocations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageRecord' {Maybe (NonEmpty UsageAllocation)
usageAllocations :: Maybe (NonEmpty UsageAllocation)
$sel:usageAllocations:UsageRecord' :: UsageRecord -> Maybe (NonEmpty UsageAllocation)
usageAllocations} -> Maybe (NonEmpty UsageAllocation)
usageAllocations) (\s :: UsageRecord
s@UsageRecord' {} Maybe (NonEmpty UsageAllocation)
a -> UsageRecord
s {$sel:usageAllocations:UsageRecord' :: Maybe (NonEmpty UsageAllocation)
usageAllocations = Maybe (NonEmpty UsageAllocation)
a} :: UsageRecord) 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
usageRecord_timestamp :: Lens.Lens' UsageRecord Prelude.UTCTime
usageRecord_timestamp :: Lens' UsageRecord UTCTime
usageRecord_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageRecord' {POSIX
timestamp :: POSIX
$sel:timestamp:UsageRecord' :: UsageRecord -> POSIX
timestamp} -> POSIX
timestamp) (\s :: UsageRecord
s@UsageRecord' {} POSIX
a -> UsageRecord
s {$sel:timestamp:UsageRecord' :: POSIX
timestamp = POSIX
a} :: UsageRecord) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time
usageRecord_customerIdentifier :: Lens.Lens' UsageRecord Prelude.Text
usageRecord_customerIdentifier :: Lens' UsageRecord Text
usageRecord_customerIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageRecord' {Text
customerIdentifier :: Text
$sel:customerIdentifier:UsageRecord' :: UsageRecord -> Text
customerIdentifier} -> Text
customerIdentifier) (\s :: UsageRecord
s@UsageRecord' {} Text
a -> UsageRecord
s {$sel:customerIdentifier:UsageRecord' :: Text
customerIdentifier = Text
a} :: UsageRecord)
usageRecord_dimension :: Lens.Lens' UsageRecord Prelude.Text
usageRecord_dimension :: Lens' UsageRecord Text
usageRecord_dimension = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageRecord' {Text
dimension :: Text
$sel:dimension:UsageRecord' :: UsageRecord -> Text
dimension} -> Text
dimension) (\s :: UsageRecord
s@UsageRecord' {} Text
a -> UsageRecord
s {$sel:dimension:UsageRecord' :: Text
dimension = Text
a} :: UsageRecord)
instance Data.FromJSON UsageRecord where
parseJSON :: Value -> Parser UsageRecord
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"UsageRecord"
( \Object
x ->
Maybe Natural
-> Maybe (NonEmpty UsageAllocation)
-> POSIX
-> Text
-> Text
-> UsageRecord
UsageRecord'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Quantity")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UsageAllocations")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Timestamp")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"CustomerIdentifier")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Dimension")
)
instance Prelude.Hashable UsageRecord where
hashWithSalt :: Int -> UsageRecord -> Int
hashWithSalt Int
_salt UsageRecord' {Maybe Natural
Maybe (NonEmpty UsageAllocation)
Text
POSIX
dimension :: Text
customerIdentifier :: Text
timestamp :: POSIX
usageAllocations :: Maybe (NonEmpty UsageAllocation)
quantity :: Maybe Natural
$sel:dimension:UsageRecord' :: UsageRecord -> Text
$sel:customerIdentifier:UsageRecord' :: UsageRecord -> Text
$sel:timestamp:UsageRecord' :: UsageRecord -> POSIX
$sel:usageAllocations:UsageRecord' :: UsageRecord -> Maybe (NonEmpty UsageAllocation)
$sel:quantity:UsageRecord' :: UsageRecord -> Maybe Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
quantity
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty UsageAllocation)
usageAllocations
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
timestamp
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
customerIdentifier
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dimension
instance Prelude.NFData UsageRecord where
rnf :: UsageRecord -> ()
rnf UsageRecord' {Maybe Natural
Maybe (NonEmpty UsageAllocation)
Text
POSIX
dimension :: Text
customerIdentifier :: Text
timestamp :: POSIX
usageAllocations :: Maybe (NonEmpty UsageAllocation)
quantity :: Maybe Natural
$sel:dimension:UsageRecord' :: UsageRecord -> Text
$sel:customerIdentifier:UsageRecord' :: UsageRecord -> Text
$sel:timestamp:UsageRecord' :: UsageRecord -> POSIX
$sel:usageAllocations:UsageRecord' :: UsageRecord -> Maybe (NonEmpty UsageAllocation)
$sel:quantity:UsageRecord' :: UsageRecord -> Maybe Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
quantity
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty UsageAllocation)
usageAllocations
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
timestamp
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
customerIdentifier
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
dimension
instance Data.ToJSON UsageRecord where
toJSON :: UsageRecord -> Value
toJSON UsageRecord' {Maybe Natural
Maybe (NonEmpty UsageAllocation)
Text
POSIX
dimension :: Text
customerIdentifier :: Text
timestamp :: POSIX
usageAllocations :: Maybe (NonEmpty UsageAllocation)
quantity :: Maybe Natural
$sel:dimension:UsageRecord' :: UsageRecord -> Text
$sel:customerIdentifier:UsageRecord' :: UsageRecord -> Text
$sel:timestamp:UsageRecord' :: UsageRecord -> POSIX
$sel:usageAllocations:UsageRecord' :: UsageRecord -> Maybe (NonEmpty UsageAllocation)
$sel:quantity:UsageRecord' :: UsageRecord -> Maybe Natural
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Quantity" 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 Natural
quantity,
(Key
"UsageAllocations" 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 (NonEmpty UsageAllocation)
usageAllocations,
forall a. a -> Maybe a
Prelude.Just (Key
"Timestamp" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= POSIX
timestamp),
forall a. a -> Maybe a
Prelude.Just
(Key
"CustomerIdentifier" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
customerIdentifier),
forall a. a -> Maybe a
Prelude.Just (Key
"Dimension" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
dimension)
]
)