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

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

-- | Contains information about a Security Hub insight.
--
-- /See:/ 'newInsight' smart constructor.
data Insight = Insight'
  { -- | The ARN of a Security Hub insight.
    Insight -> Text
insightArn :: Prelude.Text,
    -- | The name of a Security Hub insight.
    Insight -> Text
name :: Prelude.Text,
    -- | One or more attributes used to filter the findings included in the
    -- insight. The insight only includes findings that match the criteria
    -- defined in the filters.
    Insight -> AwsSecurityFindingFilters
filters :: AwsSecurityFindingFilters,
    -- | The grouping attribute for the insight\'s findings. Indicates how to
    -- group the matching findings, and identifies the type of item that the
    -- insight applies to. For example, if an insight is grouped by resource
    -- identifier, then the insight produces a list of resource identifiers.
    Insight -> Text
groupByAttribute :: Prelude.Text
  }
  deriving (Insight -> Insight -> Bool
(Insight -> Insight -> Bool)
-> (Insight -> Insight -> Bool) -> Eq Insight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Insight -> Insight -> Bool
$c/= :: Insight -> Insight -> Bool
== :: Insight -> Insight -> Bool
$c== :: Insight -> Insight -> Bool
Prelude.Eq, ReadPrec [Insight]
ReadPrec Insight
Int -> ReadS Insight
ReadS [Insight]
(Int -> ReadS Insight)
-> ReadS [Insight]
-> ReadPrec Insight
-> ReadPrec [Insight]
-> Read Insight
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Insight]
$creadListPrec :: ReadPrec [Insight]
readPrec :: ReadPrec Insight
$creadPrec :: ReadPrec Insight
readList :: ReadS [Insight]
$creadList :: ReadS [Insight]
readsPrec :: Int -> ReadS Insight
$creadsPrec :: Int -> ReadS Insight
Prelude.Read, Int -> Insight -> ShowS
[Insight] -> ShowS
Insight -> String
(Int -> Insight -> ShowS)
-> (Insight -> String) -> ([Insight] -> ShowS) -> Show Insight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Insight] -> ShowS
$cshowList :: [Insight] -> ShowS
show :: Insight -> String
$cshow :: Insight -> String
showsPrec :: Int -> Insight -> ShowS
$cshowsPrec :: Int -> Insight -> ShowS
Prelude.Show, (forall x. Insight -> Rep Insight x)
-> (forall x. Rep Insight x -> Insight) -> Generic Insight
forall x. Rep Insight x -> Insight
forall x. Insight -> Rep Insight x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Insight x -> Insight
$cfrom :: forall x. Insight -> Rep Insight x
Prelude.Generic)

-- |
-- Create a value of 'Insight' 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', 'insight_insightArn' - The ARN of a Security Hub insight.
--
-- 'name', 'insight_name' - The name of a Security Hub insight.
--
-- 'filters', 'insight_filters' - One or more attributes used to filter the findings included in the
-- insight. The insight only includes findings that match the criteria
-- defined in the filters.
--
-- 'groupByAttribute', 'insight_groupByAttribute' - The grouping attribute for the insight\'s findings. Indicates how to
-- group the matching findings, and identifies the type of item that the
-- insight applies to. For example, if an insight is grouped by resource
-- identifier, then the insight produces a list of resource identifiers.
newInsight ::
  -- | 'insightArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'filters'
  AwsSecurityFindingFilters ->
  -- | 'groupByAttribute'
  Prelude.Text ->
  Insight
newInsight :: Text -> Text -> AwsSecurityFindingFilters -> Text -> Insight
newInsight
  Text
pInsightArn_
  Text
pName_
  AwsSecurityFindingFilters
pFilters_
  Text
pGroupByAttribute_ =
    Insight' :: Text -> Text -> AwsSecurityFindingFilters -> Text -> Insight
Insight'
      { $sel:insightArn:Insight' :: Text
insightArn = Text
pInsightArn_,
        $sel:name:Insight' :: Text
name = Text
pName_,
        $sel:filters:Insight' :: AwsSecurityFindingFilters
filters = AwsSecurityFindingFilters
pFilters_,
        $sel:groupByAttribute:Insight' :: Text
groupByAttribute = Text
pGroupByAttribute_
      }

-- | The ARN of a Security Hub insight.
insight_insightArn :: Lens.Lens' Insight Prelude.Text
insight_insightArn :: (Text -> f Text) -> Insight -> f Insight
insight_insightArn = (Insight -> Text)
-> (Insight -> Text -> Insight) -> Lens Insight Insight Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Insight' {Text
insightArn :: Text
$sel:insightArn:Insight' :: Insight -> Text
insightArn} -> Text
insightArn) (\s :: Insight
s@Insight' {} Text
a -> Insight
s {$sel:insightArn:Insight' :: Text
insightArn = Text
a} :: Insight)

-- | The name of a Security Hub insight.
insight_name :: Lens.Lens' Insight Prelude.Text
insight_name :: (Text -> f Text) -> Insight -> f Insight
insight_name = (Insight -> Text)
-> (Insight -> Text -> Insight) -> Lens Insight Insight Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Insight' {Text
name :: Text
$sel:name:Insight' :: Insight -> Text
name} -> Text
name) (\s :: Insight
s@Insight' {} Text
a -> Insight
s {$sel:name:Insight' :: Text
name = Text
a} :: Insight)

-- | One or more attributes used to filter the findings included in the
-- insight. The insight only includes findings that match the criteria
-- defined in the filters.
insight_filters :: Lens.Lens' Insight AwsSecurityFindingFilters
insight_filters :: (AwsSecurityFindingFilters -> f AwsSecurityFindingFilters)
-> Insight -> f Insight
insight_filters = (Insight -> AwsSecurityFindingFilters)
-> (Insight -> AwsSecurityFindingFilters -> Insight)
-> Lens
     Insight Insight AwsSecurityFindingFilters AwsSecurityFindingFilters
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Insight' {AwsSecurityFindingFilters
filters :: AwsSecurityFindingFilters
$sel:filters:Insight' :: Insight -> AwsSecurityFindingFilters
filters} -> AwsSecurityFindingFilters
filters) (\s :: Insight
s@Insight' {} AwsSecurityFindingFilters
a -> Insight
s {$sel:filters:Insight' :: AwsSecurityFindingFilters
filters = AwsSecurityFindingFilters
a} :: Insight)

-- | The grouping attribute for the insight\'s findings. Indicates how to
-- group the matching findings, and identifies the type of item that the
-- insight applies to. For example, if an insight is grouped by resource
-- identifier, then the insight produces a list of resource identifiers.
insight_groupByAttribute :: Lens.Lens' Insight Prelude.Text
insight_groupByAttribute :: (Text -> f Text) -> Insight -> f Insight
insight_groupByAttribute = (Insight -> Text)
-> (Insight -> Text -> Insight) -> Lens Insight Insight Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Insight' {Text
groupByAttribute :: Text
$sel:groupByAttribute:Insight' :: Insight -> Text
groupByAttribute} -> Text
groupByAttribute) (\s :: Insight
s@Insight' {} Text
a -> Insight
s {$sel:groupByAttribute:Insight' :: Text
groupByAttribute = Text
a} :: Insight)

instance Core.FromJSON Insight where
  parseJSON :: Value -> Parser Insight
parseJSON =
    String -> (Object -> Parser Insight) -> Value -> Parser Insight
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Insight"
      ( \Object
x ->
          Text -> Text -> AwsSecurityFindingFilters -> Text -> Insight
Insight'
            (Text -> Text -> AwsSecurityFindingFilters -> Text -> Insight)
-> Parser Text
-> Parser (Text -> AwsSecurityFindingFilters -> Text -> Insight)
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 -> AwsSecurityFindingFilters -> Text -> Insight)
-> Parser Text
-> Parser (AwsSecurityFindingFilters -> Text -> Insight)
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
"Name")
            Parser (AwsSecurityFindingFilters -> Text -> Insight)
-> Parser AwsSecurityFindingFilters -> Parser (Text -> Insight)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AwsSecurityFindingFilters
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Filters")
            Parser (Text -> Insight) -> Parser Text -> Parser Insight
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")
      )

instance Prelude.Hashable Insight

instance Prelude.NFData Insight