{-# 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-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)
module Amazonka.GuardDuty.Types.Total where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(Total -> Total -> Bool) -> (Total -> Total -> Bool) -> Eq Total
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]
(Int -> ReadS Total)
-> ReadS [Total]
-> ReadPrec Total
-> ReadPrec [Total]
-> Read 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
(Int -> Total -> ShowS)
-> (Total -> String) -> ([Total] -> ShowS) -> Show Total
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. Total -> Rep Total x)
-> (forall x. Rep Total x -> Total) -> Generic Total
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' :: Maybe Text -> Maybe Text -> Total
Total'
    { $sel:amount:Total' :: Maybe Text
amount = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:Total' :: Maybe Text
unit = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The total usage.
total_amount :: Lens.Lens' Total (Prelude.Maybe Prelude.Text)
total_amount :: (Maybe Text -> f (Maybe Text)) -> Total -> f Total
total_amount = (Total -> Maybe Text)
-> (Total -> Maybe Text -> Total)
-> Lens Total Total (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> Total -> f Total
total_unit = (Total -> Maybe Text)
-> (Total -> Maybe Text -> Total)
-> Lens Total Total (Maybe Text) (Maybe Text)
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 Core.FromJSON Total where
  parseJSON :: Value -> Parser Total
parseJSON =
    String -> (Object -> Parser Total) -> Value -> Parser Total
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Total"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Total
Total'
            (Maybe Text -> Maybe Text -> Total)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Total)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"amount")
            Parser (Maybe Text -> Total) -> Parser (Maybe Text) -> Parser Total
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"unit")
      )

instance Prelude.Hashable Total

instance Prelude.NFData Total