{-# 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.SecurityHub.Types.InsightResultValue
-- 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.SecurityHub.Types.InsightResultValue where

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

-- | The insight result values returned by the @GetInsightResults@ operation.
--
-- /See:/ 'newInsightResultValue' smart constructor.
data InsightResultValue = InsightResultValue'
  { -- | The value of the attribute that the findings are grouped by for the
    -- insight whose results are returned by the @GetInsightResults@ operation.
    InsightResultValue -> Text
groupByAttributeValue :: Prelude.Text,
    -- | The number of findings returned for each @GroupByAttributeValue@.
    InsightResultValue -> Int
count :: Prelude.Int
  }
  deriving (InsightResultValue -> InsightResultValue -> Bool
(InsightResultValue -> InsightResultValue -> Bool)
-> (InsightResultValue -> InsightResultValue -> Bool)
-> Eq InsightResultValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InsightResultValue -> InsightResultValue -> Bool
$c/= :: InsightResultValue -> InsightResultValue -> Bool
== :: InsightResultValue -> InsightResultValue -> Bool
$c== :: InsightResultValue -> InsightResultValue -> Bool
Prelude.Eq, ReadPrec [InsightResultValue]
ReadPrec InsightResultValue
Int -> ReadS InsightResultValue
ReadS [InsightResultValue]
(Int -> ReadS InsightResultValue)
-> ReadS [InsightResultValue]
-> ReadPrec InsightResultValue
-> ReadPrec [InsightResultValue]
-> Read InsightResultValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InsightResultValue]
$creadListPrec :: ReadPrec [InsightResultValue]
readPrec :: ReadPrec InsightResultValue
$creadPrec :: ReadPrec InsightResultValue
readList :: ReadS [InsightResultValue]
$creadList :: ReadS [InsightResultValue]
readsPrec :: Int -> ReadS InsightResultValue
$creadsPrec :: Int -> ReadS InsightResultValue
Prelude.Read, Int -> InsightResultValue -> ShowS
[InsightResultValue] -> ShowS
InsightResultValue -> String
(Int -> InsightResultValue -> ShowS)
-> (InsightResultValue -> String)
-> ([InsightResultValue] -> ShowS)
-> Show InsightResultValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InsightResultValue] -> ShowS
$cshowList :: [InsightResultValue] -> ShowS
show :: InsightResultValue -> String
$cshow :: InsightResultValue -> String
showsPrec :: Int -> InsightResultValue -> ShowS
$cshowsPrec :: Int -> InsightResultValue -> ShowS
Prelude.Show, (forall x. InsightResultValue -> Rep InsightResultValue x)
-> (forall x. Rep InsightResultValue x -> InsightResultValue)
-> Generic InsightResultValue
forall x. Rep InsightResultValue x -> InsightResultValue
forall x. InsightResultValue -> Rep InsightResultValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InsightResultValue x -> InsightResultValue
$cfrom :: forall x. InsightResultValue -> Rep InsightResultValue x
Prelude.Generic)

-- |
-- Create a value of 'InsightResultValue' 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:
--
-- 'groupByAttributeValue', 'insightResultValue_groupByAttributeValue' - The value of the attribute that the findings are grouped by for the
-- insight whose results are returned by the @GetInsightResults@ operation.
--
-- 'count', 'insightResultValue_count' - The number of findings returned for each @GroupByAttributeValue@.
newInsightResultValue ::
  -- | 'groupByAttributeValue'
  Prelude.Text ->
  -- | 'count'
  Prelude.Int ->
  InsightResultValue
newInsightResultValue :: Text -> Int -> InsightResultValue
newInsightResultValue Text
pGroupByAttributeValue_ Int
pCount_ =
  InsightResultValue' :: Text -> Int -> InsightResultValue
InsightResultValue'
    { $sel:groupByAttributeValue:InsightResultValue' :: Text
groupByAttributeValue =
        Text
pGroupByAttributeValue_,
      $sel:count:InsightResultValue' :: Int
count = Int
pCount_
    }

-- | The value of the attribute that the findings are grouped by for the
-- insight whose results are returned by the @GetInsightResults@ operation.
insightResultValue_groupByAttributeValue :: Lens.Lens' InsightResultValue Prelude.Text
insightResultValue_groupByAttributeValue :: (Text -> f Text) -> InsightResultValue -> f InsightResultValue
insightResultValue_groupByAttributeValue = (InsightResultValue -> Text)
-> (InsightResultValue -> Text -> InsightResultValue)
-> Lens InsightResultValue InsightResultValue Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightResultValue' {Text
groupByAttributeValue :: Text
$sel:groupByAttributeValue:InsightResultValue' :: InsightResultValue -> Text
groupByAttributeValue} -> Text
groupByAttributeValue) (\s :: InsightResultValue
s@InsightResultValue' {} Text
a -> InsightResultValue
s {$sel:groupByAttributeValue:InsightResultValue' :: Text
groupByAttributeValue = Text
a} :: InsightResultValue)

-- | The number of findings returned for each @GroupByAttributeValue@.
insightResultValue_count :: Lens.Lens' InsightResultValue Prelude.Int
insightResultValue_count :: (Int -> f Int) -> InsightResultValue -> f InsightResultValue
insightResultValue_count = (InsightResultValue -> Int)
-> (InsightResultValue -> Int -> InsightResultValue)
-> Lens InsightResultValue InsightResultValue Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightResultValue' {Int
count :: Int
$sel:count:InsightResultValue' :: InsightResultValue -> Int
count} -> Int
count) (\s :: InsightResultValue
s@InsightResultValue' {} Int
a -> InsightResultValue
s {$sel:count:InsightResultValue' :: Int
count = Int
a} :: InsightResultValue)

instance Core.FromJSON InsightResultValue where
  parseJSON :: Value -> Parser InsightResultValue
parseJSON =
    String
-> (Object -> Parser InsightResultValue)
-> Value
-> Parser InsightResultValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InsightResultValue"
      ( \Object
x ->
          Text -> Int -> InsightResultValue
InsightResultValue'
            (Text -> Int -> InsightResultValue)
-> Parser Text -> Parser (Int -> InsightResultValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GroupByAttributeValue")
            Parser (Int -> InsightResultValue)
-> Parser Int -> Parser InsightResultValue
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Count")
      )

instance Prelude.Hashable InsightResultValue

instance Prelude.NFData InsightResultValue