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

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

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

-- |
-- Create a value of 'UsageDataSourceResult' 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', 'usageDataSourceResult_total' - Represents the total of usage for the specified data source.
--
-- 'dataSource', 'usageDataSourceResult_dataSource' - The data source type that generated usage.
newUsageDataSourceResult ::
  UsageDataSourceResult
newUsageDataSourceResult :: UsageDataSourceResult
newUsageDataSourceResult =
  UsageDataSourceResult' :: Maybe Total -> Maybe DataSource -> UsageDataSourceResult
UsageDataSourceResult'
    { $sel:total:UsageDataSourceResult' :: Maybe Total
total = Maybe Total
forall a. Maybe a
Prelude.Nothing,
      $sel:dataSource:UsageDataSourceResult' :: Maybe DataSource
dataSource = Maybe DataSource
forall a. Maybe a
Prelude.Nothing
    }

-- | Represents the total of usage for the specified data source.
usageDataSourceResult_total :: Lens.Lens' UsageDataSourceResult (Prelude.Maybe Total)
usageDataSourceResult_total :: (Maybe Total -> f (Maybe Total))
-> UsageDataSourceResult -> f UsageDataSourceResult
usageDataSourceResult_total = (UsageDataSourceResult -> Maybe Total)
-> (UsageDataSourceResult -> Maybe Total -> UsageDataSourceResult)
-> Lens
     UsageDataSourceResult
     UsageDataSourceResult
     (Maybe Total)
     (Maybe Total)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageDataSourceResult' {Maybe Total
total :: Maybe Total
$sel:total:UsageDataSourceResult' :: UsageDataSourceResult -> Maybe Total
total} -> Maybe Total
total) (\s :: UsageDataSourceResult
s@UsageDataSourceResult' {} Maybe Total
a -> UsageDataSourceResult
s {$sel:total:UsageDataSourceResult' :: Maybe Total
total = Maybe Total
a} :: UsageDataSourceResult)

-- | The data source type that generated usage.
usageDataSourceResult_dataSource :: Lens.Lens' UsageDataSourceResult (Prelude.Maybe DataSource)
usageDataSourceResult_dataSource :: (Maybe DataSource -> f (Maybe DataSource))
-> UsageDataSourceResult -> f UsageDataSourceResult
usageDataSourceResult_dataSource = (UsageDataSourceResult -> Maybe DataSource)
-> (UsageDataSourceResult
    -> Maybe DataSource -> UsageDataSourceResult)
-> Lens
     UsageDataSourceResult
     UsageDataSourceResult
     (Maybe DataSource)
     (Maybe DataSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageDataSourceResult' {Maybe DataSource
dataSource :: Maybe DataSource
$sel:dataSource:UsageDataSourceResult' :: UsageDataSourceResult -> Maybe DataSource
dataSource} -> Maybe DataSource
dataSource) (\s :: UsageDataSourceResult
s@UsageDataSourceResult' {} Maybe DataSource
a -> UsageDataSourceResult
s {$sel:dataSource:UsageDataSourceResult' :: Maybe DataSource
dataSource = Maybe DataSource
a} :: UsageDataSourceResult)

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

instance Prelude.Hashable UsageDataSourceResult

instance Prelude.NFData UsageDataSourceResult