{-# 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.UsageResourceResult
-- 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.UsageResourceResult 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 sum of usage based on an AWS resource.
--
-- /See:/ 'newUsageResourceResult' smart constructor.
data UsageResourceResult = UsageResourceResult'
  { -- | Represents the sum total of usage for the specified resource type.
    UsageResourceResult -> Maybe Total
total :: Prelude.Maybe Total,
    -- | The AWS resource that generated usage.
    UsageResourceResult -> Maybe Text
resource :: Prelude.Maybe Prelude.Text
  }
  deriving (UsageResourceResult -> UsageResourceResult -> Bool
(UsageResourceResult -> UsageResourceResult -> Bool)
-> (UsageResourceResult -> UsageResourceResult -> Bool)
-> Eq UsageResourceResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsageResourceResult -> UsageResourceResult -> Bool
$c/= :: UsageResourceResult -> UsageResourceResult -> Bool
== :: UsageResourceResult -> UsageResourceResult -> Bool
$c== :: UsageResourceResult -> UsageResourceResult -> Bool
Prelude.Eq, ReadPrec [UsageResourceResult]
ReadPrec UsageResourceResult
Int -> ReadS UsageResourceResult
ReadS [UsageResourceResult]
(Int -> ReadS UsageResourceResult)
-> ReadS [UsageResourceResult]
-> ReadPrec UsageResourceResult
-> ReadPrec [UsageResourceResult]
-> Read UsageResourceResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsageResourceResult]
$creadListPrec :: ReadPrec [UsageResourceResult]
readPrec :: ReadPrec UsageResourceResult
$creadPrec :: ReadPrec UsageResourceResult
readList :: ReadS [UsageResourceResult]
$creadList :: ReadS [UsageResourceResult]
readsPrec :: Int -> ReadS UsageResourceResult
$creadsPrec :: Int -> ReadS UsageResourceResult
Prelude.Read, Int -> UsageResourceResult -> ShowS
[UsageResourceResult] -> ShowS
UsageResourceResult -> String
(Int -> UsageResourceResult -> ShowS)
-> (UsageResourceResult -> String)
-> ([UsageResourceResult] -> ShowS)
-> Show UsageResourceResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsageResourceResult] -> ShowS
$cshowList :: [UsageResourceResult] -> ShowS
show :: UsageResourceResult -> String
$cshow :: UsageResourceResult -> String
showsPrec :: Int -> UsageResourceResult -> ShowS
$cshowsPrec :: Int -> UsageResourceResult -> ShowS
Prelude.Show, (forall x. UsageResourceResult -> Rep UsageResourceResult x)
-> (forall x. Rep UsageResourceResult x -> UsageResourceResult)
-> Generic UsageResourceResult
forall x. Rep UsageResourceResult x -> UsageResourceResult
forall x. UsageResourceResult -> Rep UsageResourceResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsageResourceResult x -> UsageResourceResult
$cfrom :: forall x. UsageResourceResult -> Rep UsageResourceResult x
Prelude.Generic)

-- |
-- Create a value of 'UsageResourceResult' 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:
--
-- 'total', 'usageResourceResult_total' - Represents the sum total of usage for the specified resource type.
--
-- 'resource', 'usageResourceResult_resource' - The AWS resource that generated usage.
newUsageResourceResult ::
  UsageResourceResult
newUsageResourceResult :: UsageResourceResult
newUsageResourceResult =
  UsageResourceResult' :: Maybe Total -> Maybe Text -> UsageResourceResult
UsageResourceResult'
    { $sel:total:UsageResourceResult' :: Maybe Total
total = Maybe Total
forall a. Maybe a
Prelude.Nothing,
      $sel:resource:UsageResourceResult' :: Maybe Text
resource = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Represents the sum total of usage for the specified resource type.
usageResourceResult_total :: Lens.Lens' UsageResourceResult (Prelude.Maybe Total)
usageResourceResult_total :: (Maybe Total -> f (Maybe Total))
-> UsageResourceResult -> f UsageResourceResult
usageResourceResult_total = (UsageResourceResult -> Maybe Total)
-> (UsageResourceResult -> Maybe Total -> UsageResourceResult)
-> Lens
     UsageResourceResult UsageResourceResult (Maybe Total) (Maybe Total)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageResourceResult' {Maybe Total
total :: Maybe Total
$sel:total:UsageResourceResult' :: UsageResourceResult -> Maybe Total
total} -> Maybe Total
total) (\s :: UsageResourceResult
s@UsageResourceResult' {} Maybe Total
a -> UsageResourceResult
s {$sel:total:UsageResourceResult' :: Maybe Total
total = Maybe Total
a} :: UsageResourceResult)

-- | The AWS resource that generated usage.
usageResourceResult_resource :: Lens.Lens' UsageResourceResult (Prelude.Maybe Prelude.Text)
usageResourceResult_resource :: (Maybe Text -> f (Maybe Text))
-> UsageResourceResult -> f UsageResourceResult
usageResourceResult_resource = (UsageResourceResult -> Maybe Text)
-> (UsageResourceResult -> Maybe Text -> UsageResourceResult)
-> Lens
     UsageResourceResult UsageResourceResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageResourceResult' {Maybe Text
resource :: Maybe Text
$sel:resource:UsageResourceResult' :: UsageResourceResult -> Maybe Text
resource} -> Maybe Text
resource) (\s :: UsageResourceResult
s@UsageResourceResult' {} Maybe Text
a -> UsageResourceResult
s {$sel:resource:UsageResourceResult' :: Maybe Text
resource = Maybe Text
a} :: UsageResourceResult)

instance Core.FromJSON UsageResourceResult where
  parseJSON :: Value -> Parser UsageResourceResult
parseJSON =
    String
-> (Object -> Parser UsageResourceResult)
-> Value
-> Parser UsageResourceResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UsageResourceResult"
      ( \Object
x ->
          Maybe Total -> Maybe Text -> UsageResourceResult
UsageResourceResult'
            (Maybe Total -> Maybe Text -> UsageResourceResult)
-> Parser (Maybe Total)
-> Parser (Maybe Text -> UsageResourceResult)
forall (f :: * -> *) a b. Functor 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")
            Parser (Maybe Text -> UsageResourceResult)
-> Parser (Maybe Text) -> Parser UsageResourceResult
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
"resource")
      )

instance Prelude.Hashable UsageResourceResult

instance Prelude.NFData UsageResourceResult