{-# 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.ValidatePolicyFinding
-- 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.AccessAnalyzer.Types.ValidatePolicyFinding where

import Amazonka.AccessAnalyzer.Types.Location
import Amazonka.AccessAnalyzer.Types.ValidatePolicyFindingType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A finding in a policy. Each finding is an actionable recommendation that
-- can be used to improve the policy.
--
-- /See:/ 'newValidatePolicyFinding' smart constructor.
data ValidatePolicyFinding = ValidatePolicyFinding'
  { -- | A localized message that explains the finding and provides guidance on
    -- how to address it.
    ValidatePolicyFinding -> Text
findingDetails :: Prelude.Text,
    -- | The impact of the finding.
    --
    -- Security warnings report when the policy allows access that we consider
    -- overly permissive.
    --
    -- Errors report when a part of the policy is not functional.
    --
    -- Warnings report non-security issues when a policy does not conform to
    -- policy writing best practices.
    --
    -- Suggestions recommend stylistic improvements in the policy that do not
    -- impact access.
    ValidatePolicyFinding -> ValidatePolicyFindingType
findingType :: ValidatePolicyFindingType,
    -- | The issue code provides an identifier of the issue associated with this
    -- finding.
    ValidatePolicyFinding -> Text
issueCode :: Prelude.Text,
    -- | A link to additional documentation about the type of finding.
    ValidatePolicyFinding -> Text
learnMoreLink :: Prelude.Text,
    -- | The list of locations in the policy document that are related to the
    -- finding. The issue code provides a summary of an issue identified by the
    -- finding.
    ValidatePolicyFinding -> [Location]
locations :: [Location]
  }
  deriving (ValidatePolicyFinding -> ValidatePolicyFinding -> Bool
(ValidatePolicyFinding -> ValidatePolicyFinding -> Bool)
-> (ValidatePolicyFinding -> ValidatePolicyFinding -> Bool)
-> Eq ValidatePolicyFinding
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ValidatePolicyFinding -> ValidatePolicyFinding -> Bool
$c/= :: ValidatePolicyFinding -> ValidatePolicyFinding -> Bool
== :: ValidatePolicyFinding -> ValidatePolicyFinding -> Bool
$c== :: ValidatePolicyFinding -> ValidatePolicyFinding -> Bool
Prelude.Eq, ReadPrec [ValidatePolicyFinding]
ReadPrec ValidatePolicyFinding
Int -> ReadS ValidatePolicyFinding
ReadS [ValidatePolicyFinding]
(Int -> ReadS ValidatePolicyFinding)
-> ReadS [ValidatePolicyFinding]
-> ReadPrec ValidatePolicyFinding
-> ReadPrec [ValidatePolicyFinding]
-> Read ValidatePolicyFinding
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ValidatePolicyFinding]
$creadListPrec :: ReadPrec [ValidatePolicyFinding]
readPrec :: ReadPrec ValidatePolicyFinding
$creadPrec :: ReadPrec ValidatePolicyFinding
readList :: ReadS [ValidatePolicyFinding]
$creadList :: ReadS [ValidatePolicyFinding]
readsPrec :: Int -> ReadS ValidatePolicyFinding
$creadsPrec :: Int -> ReadS ValidatePolicyFinding
Prelude.Read, Int -> ValidatePolicyFinding -> ShowS
[ValidatePolicyFinding] -> ShowS
ValidatePolicyFinding -> String
(Int -> ValidatePolicyFinding -> ShowS)
-> (ValidatePolicyFinding -> String)
-> ([ValidatePolicyFinding] -> ShowS)
-> Show ValidatePolicyFinding
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ValidatePolicyFinding] -> ShowS
$cshowList :: [ValidatePolicyFinding] -> ShowS
show :: ValidatePolicyFinding -> String
$cshow :: ValidatePolicyFinding -> String
showsPrec :: Int -> ValidatePolicyFinding -> ShowS
$cshowsPrec :: Int -> ValidatePolicyFinding -> ShowS
Prelude.Show, (forall x. ValidatePolicyFinding -> Rep ValidatePolicyFinding x)
-> (forall x. Rep ValidatePolicyFinding x -> ValidatePolicyFinding)
-> Generic ValidatePolicyFinding
forall x. Rep ValidatePolicyFinding x -> ValidatePolicyFinding
forall x. ValidatePolicyFinding -> Rep ValidatePolicyFinding x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ValidatePolicyFinding x -> ValidatePolicyFinding
$cfrom :: forall x. ValidatePolicyFinding -> Rep ValidatePolicyFinding x
Prelude.Generic)

-- |
-- Create a value of 'ValidatePolicyFinding' 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:
--
-- 'findingDetails', 'validatePolicyFinding_findingDetails' - A localized message that explains the finding and provides guidance on
-- how to address it.
--
-- 'findingType', 'validatePolicyFinding_findingType' - The impact of the finding.
--
-- Security warnings report when the policy allows access that we consider
-- overly permissive.
--
-- Errors report when a part of the policy is not functional.
--
-- Warnings report non-security issues when a policy does not conform to
-- policy writing best practices.
--
-- Suggestions recommend stylistic improvements in the policy that do not
-- impact access.
--
-- 'issueCode', 'validatePolicyFinding_issueCode' - The issue code provides an identifier of the issue associated with this
-- finding.
--
-- 'learnMoreLink', 'validatePolicyFinding_learnMoreLink' - A link to additional documentation about the type of finding.
--
-- 'locations', 'validatePolicyFinding_locations' - The list of locations in the policy document that are related to the
-- finding. The issue code provides a summary of an issue identified by the
-- finding.
newValidatePolicyFinding ::
  -- | 'findingDetails'
  Prelude.Text ->
  -- | 'findingType'
  ValidatePolicyFindingType ->
  -- | 'issueCode'
  Prelude.Text ->
  -- | 'learnMoreLink'
  Prelude.Text ->
  ValidatePolicyFinding
newValidatePolicyFinding :: Text
-> ValidatePolicyFindingType
-> Text
-> Text
-> ValidatePolicyFinding
newValidatePolicyFinding
  Text
pFindingDetails_
  ValidatePolicyFindingType
pFindingType_
  Text
pIssueCode_
  Text
pLearnMoreLink_ =
    ValidatePolicyFinding' :: Text
-> ValidatePolicyFindingType
-> Text
-> Text
-> [Location]
-> ValidatePolicyFinding
ValidatePolicyFinding'
      { $sel:findingDetails:ValidatePolicyFinding' :: Text
findingDetails =
          Text
pFindingDetails_,
        $sel:findingType:ValidatePolicyFinding' :: ValidatePolicyFindingType
findingType = ValidatePolicyFindingType
pFindingType_,
        $sel:issueCode:ValidatePolicyFinding' :: Text
issueCode = Text
pIssueCode_,
        $sel:learnMoreLink:ValidatePolicyFinding' :: Text
learnMoreLink = Text
pLearnMoreLink_,
        $sel:locations:ValidatePolicyFinding' :: [Location]
locations = [Location]
forall a. Monoid a => a
Prelude.mempty
      }

-- | A localized message that explains the finding and provides guidance on
-- how to address it.
validatePolicyFinding_findingDetails :: Lens.Lens' ValidatePolicyFinding Prelude.Text
validatePolicyFinding_findingDetails :: (Text -> f Text)
-> ValidatePolicyFinding -> f ValidatePolicyFinding
validatePolicyFinding_findingDetails = (ValidatePolicyFinding -> Text)
-> (ValidatePolicyFinding -> Text -> ValidatePolicyFinding)
-> Lens ValidatePolicyFinding ValidatePolicyFinding Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicyFinding' {Text
findingDetails :: Text
$sel:findingDetails:ValidatePolicyFinding' :: ValidatePolicyFinding -> Text
findingDetails} -> Text
findingDetails) (\s :: ValidatePolicyFinding
s@ValidatePolicyFinding' {} Text
a -> ValidatePolicyFinding
s {$sel:findingDetails:ValidatePolicyFinding' :: Text
findingDetails = Text
a} :: ValidatePolicyFinding)

-- | The impact of the finding.
--
-- Security warnings report when the policy allows access that we consider
-- overly permissive.
--
-- Errors report when a part of the policy is not functional.
--
-- Warnings report non-security issues when a policy does not conform to
-- policy writing best practices.
--
-- Suggestions recommend stylistic improvements in the policy that do not
-- impact access.
validatePolicyFinding_findingType :: Lens.Lens' ValidatePolicyFinding ValidatePolicyFindingType
validatePolicyFinding_findingType :: (ValidatePolicyFindingType -> f ValidatePolicyFindingType)
-> ValidatePolicyFinding -> f ValidatePolicyFinding
validatePolicyFinding_findingType = (ValidatePolicyFinding -> ValidatePolicyFindingType)
-> (ValidatePolicyFinding
    -> ValidatePolicyFindingType -> ValidatePolicyFinding)
-> Lens
     ValidatePolicyFinding
     ValidatePolicyFinding
     ValidatePolicyFindingType
     ValidatePolicyFindingType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicyFinding' {ValidatePolicyFindingType
findingType :: ValidatePolicyFindingType
$sel:findingType:ValidatePolicyFinding' :: ValidatePolicyFinding -> ValidatePolicyFindingType
findingType} -> ValidatePolicyFindingType
findingType) (\s :: ValidatePolicyFinding
s@ValidatePolicyFinding' {} ValidatePolicyFindingType
a -> ValidatePolicyFinding
s {$sel:findingType:ValidatePolicyFinding' :: ValidatePolicyFindingType
findingType = ValidatePolicyFindingType
a} :: ValidatePolicyFinding)

-- | The issue code provides an identifier of the issue associated with this
-- finding.
validatePolicyFinding_issueCode :: Lens.Lens' ValidatePolicyFinding Prelude.Text
validatePolicyFinding_issueCode :: (Text -> f Text)
-> ValidatePolicyFinding -> f ValidatePolicyFinding
validatePolicyFinding_issueCode = (ValidatePolicyFinding -> Text)
-> (ValidatePolicyFinding -> Text -> ValidatePolicyFinding)
-> Lens ValidatePolicyFinding ValidatePolicyFinding Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicyFinding' {Text
issueCode :: Text
$sel:issueCode:ValidatePolicyFinding' :: ValidatePolicyFinding -> Text
issueCode} -> Text
issueCode) (\s :: ValidatePolicyFinding
s@ValidatePolicyFinding' {} Text
a -> ValidatePolicyFinding
s {$sel:issueCode:ValidatePolicyFinding' :: Text
issueCode = Text
a} :: ValidatePolicyFinding)

-- | A link to additional documentation about the type of finding.
validatePolicyFinding_learnMoreLink :: Lens.Lens' ValidatePolicyFinding Prelude.Text
validatePolicyFinding_learnMoreLink :: (Text -> f Text)
-> ValidatePolicyFinding -> f ValidatePolicyFinding
validatePolicyFinding_learnMoreLink = (ValidatePolicyFinding -> Text)
-> (ValidatePolicyFinding -> Text -> ValidatePolicyFinding)
-> Lens ValidatePolicyFinding ValidatePolicyFinding Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicyFinding' {Text
learnMoreLink :: Text
$sel:learnMoreLink:ValidatePolicyFinding' :: ValidatePolicyFinding -> Text
learnMoreLink} -> Text
learnMoreLink) (\s :: ValidatePolicyFinding
s@ValidatePolicyFinding' {} Text
a -> ValidatePolicyFinding
s {$sel:learnMoreLink:ValidatePolicyFinding' :: Text
learnMoreLink = Text
a} :: ValidatePolicyFinding)

-- | The list of locations in the policy document that are related to the
-- finding. The issue code provides a summary of an issue identified by the
-- finding.
validatePolicyFinding_locations :: Lens.Lens' ValidatePolicyFinding [Location]
validatePolicyFinding_locations :: ([Location] -> f [Location])
-> ValidatePolicyFinding -> f ValidatePolicyFinding
validatePolicyFinding_locations = (ValidatePolicyFinding -> [Location])
-> (ValidatePolicyFinding -> [Location] -> ValidatePolicyFinding)
-> Lens
     ValidatePolicyFinding ValidatePolicyFinding [Location] [Location]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ValidatePolicyFinding' {[Location]
locations :: [Location]
$sel:locations:ValidatePolicyFinding' :: ValidatePolicyFinding -> [Location]
locations} -> [Location]
locations) (\s :: ValidatePolicyFinding
s@ValidatePolicyFinding' {} [Location]
a -> ValidatePolicyFinding
s {$sel:locations:ValidatePolicyFinding' :: [Location]
locations = [Location]
a} :: ValidatePolicyFinding) (([Location] -> f [Location])
 -> ValidatePolicyFinding -> f ValidatePolicyFinding)
-> (([Location] -> f [Location]) -> [Location] -> f [Location])
-> ([Location] -> f [Location])
-> ValidatePolicyFinding
-> f ValidatePolicyFinding
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Location] -> f [Location]) -> [Location] -> f [Location]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ValidatePolicyFinding where
  parseJSON :: Value -> Parser ValidatePolicyFinding
parseJSON =
    String
-> (Object -> Parser ValidatePolicyFinding)
-> Value
-> Parser ValidatePolicyFinding
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ValidatePolicyFinding"
      ( \Object
x ->
          Text
-> ValidatePolicyFindingType
-> Text
-> Text
-> [Location]
-> ValidatePolicyFinding
ValidatePolicyFinding'
            (Text
 -> ValidatePolicyFindingType
 -> Text
 -> Text
 -> [Location]
 -> ValidatePolicyFinding)
-> Parser Text
-> Parser
     (ValidatePolicyFindingType
      -> Text -> Text -> [Location] -> ValidatePolicyFinding)
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
"findingDetails")
            Parser
  (ValidatePolicyFindingType
   -> Text -> Text -> [Location] -> ValidatePolicyFinding)
-> Parser ValidatePolicyFindingType
-> Parser (Text -> Text -> [Location] -> ValidatePolicyFinding)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ValidatePolicyFindingType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"findingType")
            Parser (Text -> Text -> [Location] -> ValidatePolicyFinding)
-> Parser Text
-> Parser (Text -> [Location] -> ValidatePolicyFinding)
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
"issueCode")
            Parser (Text -> [Location] -> ValidatePolicyFinding)
-> Parser Text -> Parser ([Location] -> ValidatePolicyFinding)
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
"learnMoreLink")
            Parser ([Location] -> ValidatePolicyFinding)
-> Parser [Location] -> Parser ValidatePolicyFinding
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [Location])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"locations" Parser (Maybe [Location]) -> [Location] -> Parser [Location]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Location]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ValidatePolicyFinding

instance Prelude.NFData ValidatePolicyFinding