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

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

-- |
-- Module      : Amazonka.GuardDuty.Types.Total
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GuardDuty.Types.Total where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Contains the total usage with the corresponding currency unit for that
-- value.
--
-- /See:/ 'newTotal' smart constructor.
data Total = Total'
  { -- | The total usage.
    Total -> Maybe Text
amount :: Prelude.Maybe Prelude.Text,
    -- | The currency unit that the amount is given in.
    Total -> Maybe Text
unit :: Prelude.Maybe Prelude.Text
  }
  deriving (Total -> Total -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Total -> Total -> Bool
$c/= :: Total -> Total -> Bool
== :: Total -> Total -> Bool
$c== :: Total -> Total -> Bool
Prelude.Eq, ReadPrec [Total]
ReadPrec Total
Int -> ReadS Total
ReadS [Total]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Total]
$creadListPrec :: ReadPrec [Total]
readPrec :: ReadPrec Total
$creadPrec :: ReadPrec Total
readList :: ReadS [Total]
$creadList :: ReadS [Total]
readsPrec :: Int -> ReadS Total
$creadsPrec :: Int -> ReadS Total
Prelude.Read, Int -> Total -> ShowS
[Total] -> ShowS
Total -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Total] -> ShowS
$cshowList :: [Total] -> ShowS
show :: Total -> String
$cshow :: Total -> String
showsPrec :: Int -> Total -> ShowS
$cshowsPrec :: Int -> Total -> ShowS
Prelude.Show, forall x. Rep Total x -> Total
forall x. Total -> Rep Total x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Total x -> Total
$cfrom :: forall x. Total -> Rep Total x
Prelude.Generic)

-- |
-- Create a value of 'Total' 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:
--
-- 'amount', 'total_amount' - The total usage.
--
-- 'unit', 'total_unit' - The currency unit that the amount is given in.
newTotal ::
  Total
newTotal :: Total
newTotal =
  Total'
    { $sel:amount:Total' :: Maybe Text
amount = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:Total' :: Maybe Text
unit = forall a. Maybe a
Prelude.Nothing
    }

-- | The total usage.
total_amount :: Lens.Lens' Total (Prelude.Maybe Prelude.Text)
total_amount :: Lens' Total (Maybe Text)
total_amount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Total' {Maybe Text
amount :: Maybe Text
$sel:amount:Total' :: Total -> Maybe Text
amount} -> Maybe Text
amount) (\s :: Total
s@Total' {} Maybe Text
a -> Total
s {$sel:amount:Total' :: Maybe Text
amount = Maybe Text
a} :: Total)

-- | The currency unit that the amount is given in.
total_unit :: Lens.Lens' Total (Prelude.Maybe Prelude.Text)
total_unit :: Lens' Total (Maybe Text)
total_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Total' {Maybe Text
unit :: Maybe Text
$sel:unit:Total' :: Total -> Maybe Text
unit} -> Maybe Text
unit) (\s :: Total
s@Total' {} Maybe Text
a -> Total
s {$sel:unit:Total' :: Maybe Text
unit = Maybe Text
a} :: Total)

instance Data.FromJSON Total where
  parseJSON :: Value -> Parser Total
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Total"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Total
Total'
            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
"amount")
            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
"unit")
      )

instance Prelude.Hashable Total where
  hashWithSalt :: Int -> Total -> Int
hashWithSalt Int
_salt Total' {Maybe Text
unit :: Maybe Text
amount :: Maybe Text
$sel:unit:Total' :: Total -> Maybe Text
$sel:amount:Total' :: Total -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
amount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
unit

instance Prelude.NFData Total where
  rnf :: Total -> ()
rnf Total' {Maybe Text
unit :: Maybe Text
amount :: Maybe Text
$sel:unit:Total' :: Total -> Maybe Text
$sel:amount:Total' :: Total -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
amount seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
unit