{-# 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.UsageAllocation 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.Tag
import qualified Amazonka.Prelude as Prelude
data UsageAllocation = UsageAllocation'
{
UsageAllocation -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
UsageAllocation -> Natural
allocatedUsageQuantity :: Prelude.Natural
}
deriving (UsageAllocation -> UsageAllocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsageAllocation -> UsageAllocation -> Bool
$c/= :: UsageAllocation -> UsageAllocation -> Bool
== :: UsageAllocation -> UsageAllocation -> Bool
$c== :: UsageAllocation -> UsageAllocation -> Bool
Prelude.Eq, ReadPrec [UsageAllocation]
ReadPrec UsageAllocation
Int -> ReadS UsageAllocation
ReadS [UsageAllocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsageAllocation]
$creadListPrec :: ReadPrec [UsageAllocation]
readPrec :: ReadPrec UsageAllocation
$creadPrec :: ReadPrec UsageAllocation
readList :: ReadS [UsageAllocation]
$creadList :: ReadS [UsageAllocation]
readsPrec :: Int -> ReadS UsageAllocation
$creadsPrec :: Int -> ReadS UsageAllocation
Prelude.Read, Int -> UsageAllocation -> ShowS
[UsageAllocation] -> ShowS
UsageAllocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsageAllocation] -> ShowS
$cshowList :: [UsageAllocation] -> ShowS
show :: UsageAllocation -> String
$cshow :: UsageAllocation -> String
showsPrec :: Int -> UsageAllocation -> ShowS
$cshowsPrec :: Int -> UsageAllocation -> ShowS
Prelude.Show, forall x. Rep UsageAllocation x -> UsageAllocation
forall x. UsageAllocation -> Rep UsageAllocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsageAllocation x -> UsageAllocation
$cfrom :: forall x. UsageAllocation -> Rep UsageAllocation x
Prelude.Generic)
newUsageAllocation ::
Prelude.Natural ->
UsageAllocation
newUsageAllocation :: Natural -> UsageAllocation
newUsageAllocation Natural
pAllocatedUsageQuantity_ =
UsageAllocation'
{ $sel:tags:UsageAllocation' :: Maybe (NonEmpty Tag)
tags = forall a. Maybe a
Prelude.Nothing,
$sel:allocatedUsageQuantity:UsageAllocation' :: Natural
allocatedUsageQuantity = Natural
pAllocatedUsageQuantity_
}
usageAllocation_tags :: Lens.Lens' UsageAllocation (Prelude.Maybe (Prelude.NonEmpty Tag))
usageAllocation_tags :: Lens' UsageAllocation (Maybe (NonEmpty Tag))
usageAllocation_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageAllocation' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:UsageAllocation' :: UsageAllocation -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: UsageAllocation
s@UsageAllocation' {} Maybe (NonEmpty Tag)
a -> UsageAllocation
s {$sel:tags:UsageAllocation' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: UsageAllocation) 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
usageAllocation_allocatedUsageQuantity :: Lens.Lens' UsageAllocation Prelude.Natural
usageAllocation_allocatedUsageQuantity :: Lens' UsageAllocation Natural
usageAllocation_allocatedUsageQuantity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageAllocation' {Natural
allocatedUsageQuantity :: Natural
$sel:allocatedUsageQuantity:UsageAllocation' :: UsageAllocation -> Natural
allocatedUsageQuantity} -> Natural
allocatedUsageQuantity) (\s :: UsageAllocation
s@UsageAllocation' {} Natural
a -> UsageAllocation
s {$sel:allocatedUsageQuantity:UsageAllocation' :: Natural
allocatedUsageQuantity = Natural
a} :: UsageAllocation)
instance Data.FromJSON UsageAllocation where
parseJSON :: Value -> Parser UsageAllocation
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"UsageAllocation"
( \Object
x ->
Maybe (NonEmpty Tag) -> Natural -> UsageAllocation
UsageAllocation'
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
"Tags")
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
"AllocatedUsageQuantity")
)
instance Prelude.Hashable UsageAllocation where
hashWithSalt :: Int -> UsageAllocation -> Int
hashWithSalt Int
_salt UsageAllocation' {Natural
Maybe (NonEmpty Tag)
allocatedUsageQuantity :: Natural
tags :: Maybe (NonEmpty Tag)
$sel:allocatedUsageQuantity:UsageAllocation' :: UsageAllocation -> Natural
$sel:tags:UsageAllocation' :: UsageAllocation -> Maybe (NonEmpty Tag)
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Tag)
tags
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
allocatedUsageQuantity
instance Prelude.NFData UsageAllocation where
rnf :: UsageAllocation -> ()
rnf UsageAllocation' {Natural
Maybe (NonEmpty Tag)
allocatedUsageQuantity :: Natural
tags :: Maybe (NonEmpty Tag)
$sel:allocatedUsageQuantity:UsageAllocation' :: UsageAllocation -> Natural
$sel:tags:UsageAllocation' :: UsageAllocation -> Maybe (NonEmpty Tag)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Tag)
tags
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
allocatedUsageQuantity
instance Data.ToJSON UsageAllocation where
toJSON :: UsageAllocation -> Value
toJSON UsageAllocation' {Natural
Maybe (NonEmpty Tag)
allocatedUsageQuantity :: Natural
tags :: Maybe (NonEmpty Tag)
$sel:allocatedUsageQuantity:UsageAllocation' :: UsageAllocation -> Natural
$sel:tags:UsageAllocation' :: UsageAllocation -> Maybe (NonEmpty Tag)
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Tags" 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 Tag)
tags,
forall a. a -> Maybe a
Prelude.Just
( Key
"AllocatedUsageQuantity"
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
allocatedUsageQuantity
)
]
)