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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.InsightResultValue

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

-- |
-- Create a value of 'InsightResults' 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:
--
-- 'insightArn', 'insightResults_insightArn' - The ARN of the insight whose results are returned by the
-- @GetInsightResults@ operation.
--
-- 'groupByAttribute', 'insightResults_groupByAttribute' - The attribute that the findings are grouped by for the insight whose
-- results are returned by the @GetInsightResults@ operation.
--
-- 'resultValues', 'insightResults_resultValues' - The list of insight result values returned by the @GetInsightResults@
-- operation.
newInsightResults ::
  -- | 'insightArn'
  Prelude.Text ->
  -- | 'groupByAttribute'
  Prelude.Text ->
  InsightResults
newInsightResults :: Text -> Text -> InsightResults
newInsightResults Text
pInsightArn_ Text
pGroupByAttribute_ =
  InsightResults' :: Text -> Text -> [InsightResultValue] -> InsightResults
InsightResults'
    { $sel:insightArn:InsightResults' :: Text
insightArn = Text
pInsightArn_,
      $sel:groupByAttribute:InsightResults' :: Text
groupByAttribute = Text
pGroupByAttribute_,
      $sel:resultValues:InsightResults' :: [InsightResultValue]
resultValues = [InsightResultValue]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The ARN of the insight whose results are returned by the
-- @GetInsightResults@ operation.
insightResults_insightArn :: Lens.Lens' InsightResults Prelude.Text
insightResults_insightArn :: (Text -> f Text) -> InsightResults -> f InsightResults
insightResults_insightArn = (InsightResults -> Text)
-> (InsightResults -> Text -> InsightResults)
-> Lens InsightResults InsightResults Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightResults' {Text
insightArn :: Text
$sel:insightArn:InsightResults' :: InsightResults -> Text
insightArn} -> Text
insightArn) (\s :: InsightResults
s@InsightResults' {} Text
a -> InsightResults
s {$sel:insightArn:InsightResults' :: Text
insightArn = Text
a} :: InsightResults)

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

-- | The list of insight result values returned by the @GetInsightResults@
-- operation.
insightResults_resultValues :: Lens.Lens' InsightResults [InsightResultValue]
insightResults_resultValues :: ([InsightResultValue] -> f [InsightResultValue])
-> InsightResults -> f InsightResults
insightResults_resultValues = (InsightResults -> [InsightResultValue])
-> (InsightResults -> [InsightResultValue] -> InsightResults)
-> Lens
     InsightResults
     InsightResults
     [InsightResultValue]
     [InsightResultValue]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightResults' {[InsightResultValue]
resultValues :: [InsightResultValue]
$sel:resultValues:InsightResults' :: InsightResults -> [InsightResultValue]
resultValues} -> [InsightResultValue]
resultValues) (\s :: InsightResults
s@InsightResults' {} [InsightResultValue]
a -> InsightResults
s {$sel:resultValues:InsightResults' :: [InsightResultValue]
resultValues = [InsightResultValue]
a} :: InsightResults) (([InsightResultValue] -> f [InsightResultValue])
 -> InsightResults -> f InsightResults)
-> (([InsightResultValue] -> f [InsightResultValue])
    -> [InsightResultValue] -> f [InsightResultValue])
-> ([InsightResultValue] -> f [InsightResultValue])
-> InsightResults
-> f InsightResults
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([InsightResultValue] -> f [InsightResultValue])
-> [InsightResultValue] -> f [InsightResultValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON InsightResults where
  parseJSON :: Value -> Parser InsightResults
parseJSON =
    String
-> (Object -> Parser InsightResults)
-> Value
-> Parser InsightResults
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InsightResults"
      ( \Object
x ->
          Text -> Text -> [InsightResultValue] -> InsightResults
InsightResults'
            (Text -> Text -> [InsightResultValue] -> InsightResults)
-> Parser Text
-> Parser (Text -> [InsightResultValue] -> InsightResults)
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
"InsightArn")
            Parser (Text -> [InsightResultValue] -> InsightResults)
-> Parser Text -> Parser ([InsightResultValue] -> InsightResults)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GroupByAttribute")
            Parser ([InsightResultValue] -> InsightResults)
-> Parser [InsightResultValue] -> Parser InsightResults
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [InsightResultValue])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResultValues" Parser (Maybe [InsightResultValue])
-> [InsightResultValue] -> Parser [InsightResultValue]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [InsightResultValue]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable InsightResults

instance Prelude.NFData InsightResults