{-# 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.UsageAccountResult
-- 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.UsageAccountResult where

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.Types.Total
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information on the total of usage based on account IDs.
--
-- /See:/ 'newUsageAccountResult' smart constructor.
data UsageAccountResult = UsageAccountResult'
  { -- | The Account ID that generated usage.
    UsageAccountResult -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | Represents the total of usage for the Account ID.
    UsageAccountResult -> Maybe Total
total :: Prelude.Maybe Total
  }
  deriving (UsageAccountResult -> UsageAccountResult -> Bool
(UsageAccountResult -> UsageAccountResult -> Bool)
-> (UsageAccountResult -> UsageAccountResult -> Bool)
-> Eq UsageAccountResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsageAccountResult -> UsageAccountResult -> Bool
$c/= :: UsageAccountResult -> UsageAccountResult -> Bool
== :: UsageAccountResult -> UsageAccountResult -> Bool
$c== :: UsageAccountResult -> UsageAccountResult -> Bool
Prelude.Eq, ReadPrec [UsageAccountResult]
ReadPrec UsageAccountResult
Int -> ReadS UsageAccountResult
ReadS [UsageAccountResult]
(Int -> ReadS UsageAccountResult)
-> ReadS [UsageAccountResult]
-> ReadPrec UsageAccountResult
-> ReadPrec [UsageAccountResult]
-> Read UsageAccountResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsageAccountResult]
$creadListPrec :: ReadPrec [UsageAccountResult]
readPrec :: ReadPrec UsageAccountResult
$creadPrec :: ReadPrec UsageAccountResult
readList :: ReadS [UsageAccountResult]
$creadList :: ReadS [UsageAccountResult]
readsPrec :: Int -> ReadS UsageAccountResult
$creadsPrec :: Int -> ReadS UsageAccountResult
Prelude.Read, Int -> UsageAccountResult -> ShowS
[UsageAccountResult] -> ShowS
UsageAccountResult -> String
(Int -> UsageAccountResult -> ShowS)
-> (UsageAccountResult -> String)
-> ([UsageAccountResult] -> ShowS)
-> Show UsageAccountResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsageAccountResult] -> ShowS
$cshowList :: [UsageAccountResult] -> ShowS
show :: UsageAccountResult -> String
$cshow :: UsageAccountResult -> String
showsPrec :: Int -> UsageAccountResult -> ShowS
$cshowsPrec :: Int -> UsageAccountResult -> ShowS
Prelude.Show, (forall x. UsageAccountResult -> Rep UsageAccountResult x)
-> (forall x. Rep UsageAccountResult x -> UsageAccountResult)
-> Generic UsageAccountResult
forall x. Rep UsageAccountResult x -> UsageAccountResult
forall x. UsageAccountResult -> Rep UsageAccountResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsageAccountResult x -> UsageAccountResult
$cfrom :: forall x. UsageAccountResult -> Rep UsageAccountResult x
Prelude.Generic)

-- |
-- Create a value of 'UsageAccountResult' 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:
--
-- 'accountId', 'usageAccountResult_accountId' - The Account ID that generated usage.
--
-- 'total', 'usageAccountResult_total' - Represents the total of usage for the Account ID.
newUsageAccountResult ::
  UsageAccountResult
newUsageAccountResult :: UsageAccountResult
newUsageAccountResult =
  UsageAccountResult' :: Maybe Text -> Maybe Total -> UsageAccountResult
UsageAccountResult'
    { $sel:accountId:UsageAccountResult' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:total:UsageAccountResult' :: Maybe Total
total = Maybe Total
forall a. Maybe a
Prelude.Nothing
    }

-- | The Account ID that generated usage.
usageAccountResult_accountId :: Lens.Lens' UsageAccountResult (Prelude.Maybe Prelude.Text)
usageAccountResult_accountId :: (Maybe Text -> f (Maybe Text))
-> UsageAccountResult -> f UsageAccountResult
usageAccountResult_accountId = (UsageAccountResult -> Maybe Text)
-> (UsageAccountResult -> Maybe Text -> UsageAccountResult)
-> Lens
     UsageAccountResult UsageAccountResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageAccountResult' {Maybe Text
accountId :: Maybe Text
$sel:accountId:UsageAccountResult' :: UsageAccountResult -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: UsageAccountResult
s@UsageAccountResult' {} Maybe Text
a -> UsageAccountResult
s {$sel:accountId:UsageAccountResult' :: Maybe Text
accountId = Maybe Text
a} :: UsageAccountResult)

-- | Represents the total of usage for the Account ID.
usageAccountResult_total :: Lens.Lens' UsageAccountResult (Prelude.Maybe Total)
usageAccountResult_total :: (Maybe Total -> f (Maybe Total))
-> UsageAccountResult -> f UsageAccountResult
usageAccountResult_total = (UsageAccountResult -> Maybe Total)
-> (UsageAccountResult -> Maybe Total -> UsageAccountResult)
-> Lens
     UsageAccountResult UsageAccountResult (Maybe Total) (Maybe Total)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageAccountResult' {Maybe Total
total :: Maybe Total
$sel:total:UsageAccountResult' :: UsageAccountResult -> Maybe Total
total} -> Maybe Total
total) (\s :: UsageAccountResult
s@UsageAccountResult' {} Maybe Total
a -> UsageAccountResult
s {$sel:total:UsageAccountResult' :: Maybe Total
total = Maybe Total
a} :: UsageAccountResult)

instance Core.FromJSON UsageAccountResult where
  parseJSON :: Value -> Parser UsageAccountResult
parseJSON =
    String
-> (Object -> Parser UsageAccountResult)
-> Value
-> Parser UsageAccountResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UsageAccountResult"
      ( \Object
x ->
          Maybe Text -> Maybe Total -> UsageAccountResult
UsageAccountResult'
            (Maybe Text -> Maybe Total -> UsageAccountResult)
-> Parser (Maybe Text)
-> Parser (Maybe Total -> UsageAccountResult)
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
"accountId")
            Parser (Maybe Total -> UsageAccountResult)
-> Parser (Maybe Total) -> Parser UsageAccountResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Total)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"total")
      )

instance Prelude.Hashable UsageAccountResult

instance Prelude.NFData UsageAccountResult