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

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

-- | An instance of a threat intelligence detail that constitutes evidence
-- for the finding.
--
-- /See:/ 'newThreatIntelligenceDetail' smart constructor.
data ThreatIntelligenceDetail = ThreatIntelligenceDetail'
  { -- | A list of names of the threats in the threat intelligence list that
    -- triggered the finding.
    ThreatIntelligenceDetail -> Maybe [Text]
threatNames :: Prelude.Maybe [Prelude.Text],
    -- | The name of the threat intelligence list that triggered the finding.
    ThreatIntelligenceDetail -> Maybe Text
threatListName :: Prelude.Maybe Prelude.Text
  }
  deriving (ThreatIntelligenceDetail -> ThreatIntelligenceDetail -> Bool
(ThreatIntelligenceDetail -> ThreatIntelligenceDetail -> Bool)
-> (ThreatIntelligenceDetail -> ThreatIntelligenceDetail -> Bool)
-> Eq ThreatIntelligenceDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThreatIntelligenceDetail -> ThreatIntelligenceDetail -> Bool
$c/= :: ThreatIntelligenceDetail -> ThreatIntelligenceDetail -> Bool
== :: ThreatIntelligenceDetail -> ThreatIntelligenceDetail -> Bool
$c== :: ThreatIntelligenceDetail -> ThreatIntelligenceDetail -> Bool
Prelude.Eq, ReadPrec [ThreatIntelligenceDetail]
ReadPrec ThreatIntelligenceDetail
Int -> ReadS ThreatIntelligenceDetail
ReadS [ThreatIntelligenceDetail]
(Int -> ReadS ThreatIntelligenceDetail)
-> ReadS [ThreatIntelligenceDetail]
-> ReadPrec ThreatIntelligenceDetail
-> ReadPrec [ThreatIntelligenceDetail]
-> Read ThreatIntelligenceDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThreatIntelligenceDetail]
$creadListPrec :: ReadPrec [ThreatIntelligenceDetail]
readPrec :: ReadPrec ThreatIntelligenceDetail
$creadPrec :: ReadPrec ThreatIntelligenceDetail
readList :: ReadS [ThreatIntelligenceDetail]
$creadList :: ReadS [ThreatIntelligenceDetail]
readsPrec :: Int -> ReadS ThreatIntelligenceDetail
$creadsPrec :: Int -> ReadS ThreatIntelligenceDetail
Prelude.Read, Int -> ThreatIntelligenceDetail -> ShowS
[ThreatIntelligenceDetail] -> ShowS
ThreatIntelligenceDetail -> String
(Int -> ThreatIntelligenceDetail -> ShowS)
-> (ThreatIntelligenceDetail -> String)
-> ([ThreatIntelligenceDetail] -> ShowS)
-> Show ThreatIntelligenceDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThreatIntelligenceDetail] -> ShowS
$cshowList :: [ThreatIntelligenceDetail] -> ShowS
show :: ThreatIntelligenceDetail -> String
$cshow :: ThreatIntelligenceDetail -> String
showsPrec :: Int -> ThreatIntelligenceDetail -> ShowS
$cshowsPrec :: Int -> ThreatIntelligenceDetail -> ShowS
Prelude.Show, (forall x.
 ThreatIntelligenceDetail -> Rep ThreatIntelligenceDetail x)
-> (forall x.
    Rep ThreatIntelligenceDetail x -> ThreatIntelligenceDetail)
-> Generic ThreatIntelligenceDetail
forall x.
Rep ThreatIntelligenceDetail x -> ThreatIntelligenceDetail
forall x.
ThreatIntelligenceDetail -> Rep ThreatIntelligenceDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ThreatIntelligenceDetail x -> ThreatIntelligenceDetail
$cfrom :: forall x.
ThreatIntelligenceDetail -> Rep ThreatIntelligenceDetail x
Prelude.Generic)

-- |
-- Create a value of 'ThreatIntelligenceDetail' 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:
--
-- 'threatNames', 'threatIntelligenceDetail_threatNames' - A list of names of the threats in the threat intelligence list that
-- triggered the finding.
--
-- 'threatListName', 'threatIntelligenceDetail_threatListName' - The name of the threat intelligence list that triggered the finding.
newThreatIntelligenceDetail ::
  ThreatIntelligenceDetail
newThreatIntelligenceDetail :: ThreatIntelligenceDetail
newThreatIntelligenceDetail =
  ThreatIntelligenceDetail' :: Maybe [Text] -> Maybe Text -> ThreatIntelligenceDetail
ThreatIntelligenceDetail'
    { $sel:threatNames:ThreatIntelligenceDetail' :: Maybe [Text]
threatNames =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:threatListName:ThreatIntelligenceDetail' :: Maybe Text
threatListName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of names of the threats in the threat intelligence list that
-- triggered the finding.
threatIntelligenceDetail_threatNames :: Lens.Lens' ThreatIntelligenceDetail (Prelude.Maybe [Prelude.Text])
threatIntelligenceDetail_threatNames :: (Maybe [Text] -> f (Maybe [Text]))
-> ThreatIntelligenceDetail -> f ThreatIntelligenceDetail
threatIntelligenceDetail_threatNames = (ThreatIntelligenceDetail -> Maybe [Text])
-> (ThreatIntelligenceDetail
    -> Maybe [Text] -> ThreatIntelligenceDetail)
-> Lens
     ThreatIntelligenceDetail
     ThreatIntelligenceDetail
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThreatIntelligenceDetail' {Maybe [Text]
threatNames :: Maybe [Text]
$sel:threatNames:ThreatIntelligenceDetail' :: ThreatIntelligenceDetail -> Maybe [Text]
threatNames} -> Maybe [Text]
threatNames) (\s :: ThreatIntelligenceDetail
s@ThreatIntelligenceDetail' {} Maybe [Text]
a -> ThreatIntelligenceDetail
s {$sel:threatNames:ThreatIntelligenceDetail' :: Maybe [Text]
threatNames = Maybe [Text]
a} :: ThreatIntelligenceDetail) ((Maybe [Text] -> f (Maybe [Text]))
 -> ThreatIntelligenceDetail -> f ThreatIntelligenceDetail)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ThreatIntelligenceDetail
-> f ThreatIntelligenceDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the threat intelligence list that triggered the finding.
threatIntelligenceDetail_threatListName :: Lens.Lens' ThreatIntelligenceDetail (Prelude.Maybe Prelude.Text)
threatIntelligenceDetail_threatListName :: (Maybe Text -> f (Maybe Text))
-> ThreatIntelligenceDetail -> f ThreatIntelligenceDetail
threatIntelligenceDetail_threatListName = (ThreatIntelligenceDetail -> Maybe Text)
-> (ThreatIntelligenceDetail
    -> Maybe Text -> ThreatIntelligenceDetail)
-> Lens
     ThreatIntelligenceDetail
     ThreatIntelligenceDetail
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThreatIntelligenceDetail' {Maybe Text
threatListName :: Maybe Text
$sel:threatListName:ThreatIntelligenceDetail' :: ThreatIntelligenceDetail -> Maybe Text
threatListName} -> Maybe Text
threatListName) (\s :: ThreatIntelligenceDetail
s@ThreatIntelligenceDetail' {} Maybe Text
a -> ThreatIntelligenceDetail
s {$sel:threatListName:ThreatIntelligenceDetail' :: Maybe Text
threatListName = Maybe Text
a} :: ThreatIntelligenceDetail)

instance Core.FromJSON ThreatIntelligenceDetail where
  parseJSON :: Value -> Parser ThreatIntelligenceDetail
parseJSON =
    String
-> (Object -> Parser ThreatIntelligenceDetail)
-> Value
-> Parser ThreatIntelligenceDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ThreatIntelligenceDetail"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> ThreatIntelligenceDetail
ThreatIntelligenceDetail'
            (Maybe [Text] -> Maybe Text -> ThreatIntelligenceDetail)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> ThreatIntelligenceDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"threatNames" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> ThreatIntelligenceDetail)
-> Parser (Maybe Text) -> Parser ThreatIntelligenceDetail
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
"threatListName")
      )

instance Prelude.Hashable ThreatIntelligenceDetail

instance Prelude.NFData ThreatIntelligenceDetail