{-# 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.AccessAnalyzer.Types.FindingSource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AccessAnalyzer.Types.FindingSource where

import Amazonka.AccessAnalyzer.Types.FindingSourceDetail
import Amazonka.AccessAnalyzer.Types.FindingSourceType
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The source of the finding. This indicates how the access that generated
-- the finding is granted. It is populated for Amazon S3 bucket findings.
--
-- /See:/ 'newFindingSource' smart constructor.
data FindingSource = FindingSource'
  { -- | Includes details about how the access that generated the finding is
    -- granted. This is populated for Amazon S3 bucket findings.
    FindingSource -> Maybe FindingSourceDetail
detail :: Prelude.Maybe FindingSourceDetail,
    -- | Indicates the type of access that generated the finding.
    FindingSource -> FindingSourceType
type' :: FindingSourceType
  }
  deriving (FindingSource -> FindingSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FindingSource -> FindingSource -> Bool
$c/= :: FindingSource -> FindingSource -> Bool
== :: FindingSource -> FindingSource -> Bool
$c== :: FindingSource -> FindingSource -> Bool
Prelude.Eq, ReadPrec [FindingSource]
ReadPrec FindingSource
Int -> ReadS FindingSource
ReadS [FindingSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FindingSource]
$creadListPrec :: ReadPrec [FindingSource]
readPrec :: ReadPrec FindingSource
$creadPrec :: ReadPrec FindingSource
readList :: ReadS [FindingSource]
$creadList :: ReadS [FindingSource]
readsPrec :: Int -> ReadS FindingSource
$creadsPrec :: Int -> ReadS FindingSource
Prelude.Read, Int -> FindingSource -> ShowS
[FindingSource] -> ShowS
FindingSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FindingSource] -> ShowS
$cshowList :: [FindingSource] -> ShowS
show :: FindingSource -> String
$cshow :: FindingSource -> String
showsPrec :: Int -> FindingSource -> ShowS
$cshowsPrec :: Int -> FindingSource -> ShowS
Prelude.Show, forall x. Rep FindingSource x -> FindingSource
forall x. FindingSource -> Rep FindingSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FindingSource x -> FindingSource
$cfrom :: forall x. FindingSource -> Rep FindingSource x
Prelude.Generic)

-- |
-- Create a value of 'FindingSource' 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:
--
-- 'detail', 'findingSource_detail' - Includes details about how the access that generated the finding is
-- granted. This is populated for Amazon S3 bucket findings.
--
-- 'type'', 'findingSource_type' - Indicates the type of access that generated the finding.
newFindingSource ::
  -- | 'type''
  FindingSourceType ->
  FindingSource
newFindingSource :: FindingSourceType -> FindingSource
newFindingSource FindingSourceType
pType_ =
  FindingSource'
    { $sel:detail:FindingSource' :: Maybe FindingSourceDetail
detail = forall a. Maybe a
Prelude.Nothing,
      $sel:type':FindingSource' :: FindingSourceType
type' = FindingSourceType
pType_
    }

-- | Includes details about how the access that generated the finding is
-- granted. This is populated for Amazon S3 bucket findings.
findingSource_detail :: Lens.Lens' FindingSource (Prelude.Maybe FindingSourceDetail)
findingSource_detail :: Lens' FindingSource (Maybe FindingSourceDetail)
findingSource_detail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingSource' {Maybe FindingSourceDetail
detail :: Maybe FindingSourceDetail
$sel:detail:FindingSource' :: FindingSource -> Maybe FindingSourceDetail
detail} -> Maybe FindingSourceDetail
detail) (\s :: FindingSource
s@FindingSource' {} Maybe FindingSourceDetail
a -> FindingSource
s {$sel:detail:FindingSource' :: Maybe FindingSourceDetail
detail = Maybe FindingSourceDetail
a} :: FindingSource)

-- | Indicates the type of access that generated the finding.
findingSource_type :: Lens.Lens' FindingSource FindingSourceType
findingSource_type :: Lens' FindingSource FindingSourceType
findingSource_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingSource' {FindingSourceType
type' :: FindingSourceType
$sel:type':FindingSource' :: FindingSource -> FindingSourceType
type'} -> FindingSourceType
type') (\s :: FindingSource
s@FindingSource' {} FindingSourceType
a -> FindingSource
s {$sel:type':FindingSource' :: FindingSourceType
type' = FindingSourceType
a} :: FindingSource)

instance Data.FromJSON FindingSource where
  parseJSON :: Value -> Parser FindingSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FindingSource"
      ( \Object
x ->
          Maybe FindingSourceDetail -> FindingSourceType -> FindingSource
FindingSource'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"detail")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"type")
      )

instance Prelude.Hashable FindingSource where
  hashWithSalt :: Int -> FindingSource -> Int
hashWithSalt Int
_salt FindingSource' {Maybe FindingSourceDetail
FindingSourceType
type' :: FindingSourceType
detail :: Maybe FindingSourceDetail
$sel:type':FindingSource' :: FindingSource -> FindingSourceType
$sel:detail:FindingSource' :: FindingSource -> Maybe FindingSourceDetail
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FindingSourceDetail
detail
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FindingSourceType
type'

instance Prelude.NFData FindingSource where
  rnf :: FindingSource -> ()
rnf FindingSource' {Maybe FindingSourceDetail
FindingSourceType
type' :: FindingSourceType
detail :: Maybe FindingSourceDetail
$sel:type':FindingSource' :: FindingSource -> FindingSourceType
$sel:detail:FindingSource' :: FindingSource -> Maybe FindingSourceDetail
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FindingSourceDetail
detail seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf FindingSourceType
type'