{-# 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.FMS.Types.AwsVPCSecurityGroupViolation
-- 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.FMS.Types.AwsVPCSecurityGroupViolation where

import qualified Amazonka.Core as Core
import Amazonka.FMS.Types.PartialMatch
import Amazonka.FMS.Types.SecurityGroupRemediationAction
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Violation detail for the rule violation in a security group when
-- compared to the primary security group of the Firewall Manager policy.
--
-- /See:/ 'newAwsVPCSecurityGroupViolation' smart constructor.
data AwsVPCSecurityGroupViolation = AwsVPCSecurityGroupViolation'
  { -- | A description of the security group that violates the policy.
    AwsVPCSecurityGroupViolation -> Maybe Text
violationTargetDescription :: Prelude.Maybe Prelude.Text,
    -- | Remediation options for the rule specified in the @ViolationTarget@.
    AwsVPCSecurityGroupViolation
-> Maybe [SecurityGroupRemediationAction]
possibleSecurityGroupRemediationActions :: Prelude.Maybe [SecurityGroupRemediationAction],
    -- | The security group rule that is being evaluated.
    AwsVPCSecurityGroupViolation -> Maybe Text
violationTarget :: Prelude.Maybe Prelude.Text,
    -- | List of rules specified in the security group of the Firewall Manager
    -- policy that partially match the @ViolationTarget@ rule.
    AwsVPCSecurityGroupViolation -> Maybe [PartialMatch]
partialMatches :: Prelude.Maybe [PartialMatch]
  }
  deriving (AwsVPCSecurityGroupViolation
-> AwsVPCSecurityGroupViolation -> Bool
(AwsVPCSecurityGroupViolation
 -> AwsVPCSecurityGroupViolation -> Bool)
-> (AwsVPCSecurityGroupViolation
    -> AwsVPCSecurityGroupViolation -> Bool)
-> Eq AwsVPCSecurityGroupViolation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsVPCSecurityGroupViolation
-> AwsVPCSecurityGroupViolation -> Bool
$c/= :: AwsVPCSecurityGroupViolation
-> AwsVPCSecurityGroupViolation -> Bool
== :: AwsVPCSecurityGroupViolation
-> AwsVPCSecurityGroupViolation -> Bool
$c== :: AwsVPCSecurityGroupViolation
-> AwsVPCSecurityGroupViolation -> Bool
Prelude.Eq, ReadPrec [AwsVPCSecurityGroupViolation]
ReadPrec AwsVPCSecurityGroupViolation
Int -> ReadS AwsVPCSecurityGroupViolation
ReadS [AwsVPCSecurityGroupViolation]
(Int -> ReadS AwsVPCSecurityGroupViolation)
-> ReadS [AwsVPCSecurityGroupViolation]
-> ReadPrec AwsVPCSecurityGroupViolation
-> ReadPrec [AwsVPCSecurityGroupViolation]
-> Read AwsVPCSecurityGroupViolation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsVPCSecurityGroupViolation]
$creadListPrec :: ReadPrec [AwsVPCSecurityGroupViolation]
readPrec :: ReadPrec AwsVPCSecurityGroupViolation
$creadPrec :: ReadPrec AwsVPCSecurityGroupViolation
readList :: ReadS [AwsVPCSecurityGroupViolation]
$creadList :: ReadS [AwsVPCSecurityGroupViolation]
readsPrec :: Int -> ReadS AwsVPCSecurityGroupViolation
$creadsPrec :: Int -> ReadS AwsVPCSecurityGroupViolation
Prelude.Read, Int -> AwsVPCSecurityGroupViolation -> ShowS
[AwsVPCSecurityGroupViolation] -> ShowS
AwsVPCSecurityGroupViolation -> String
(Int -> AwsVPCSecurityGroupViolation -> ShowS)
-> (AwsVPCSecurityGroupViolation -> String)
-> ([AwsVPCSecurityGroupViolation] -> ShowS)
-> Show AwsVPCSecurityGroupViolation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsVPCSecurityGroupViolation] -> ShowS
$cshowList :: [AwsVPCSecurityGroupViolation] -> ShowS
show :: AwsVPCSecurityGroupViolation -> String
$cshow :: AwsVPCSecurityGroupViolation -> String
showsPrec :: Int -> AwsVPCSecurityGroupViolation -> ShowS
$cshowsPrec :: Int -> AwsVPCSecurityGroupViolation -> ShowS
Prelude.Show, (forall x.
 AwsVPCSecurityGroupViolation -> Rep AwsVPCSecurityGroupViolation x)
-> (forall x.
    Rep AwsVPCSecurityGroupViolation x -> AwsVPCSecurityGroupViolation)
-> Generic AwsVPCSecurityGroupViolation
forall x.
Rep AwsVPCSecurityGroupViolation x -> AwsVPCSecurityGroupViolation
forall x.
AwsVPCSecurityGroupViolation -> Rep AwsVPCSecurityGroupViolation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsVPCSecurityGroupViolation x -> AwsVPCSecurityGroupViolation
$cfrom :: forall x.
AwsVPCSecurityGroupViolation -> Rep AwsVPCSecurityGroupViolation x
Prelude.Generic)

-- |
-- Create a value of 'AwsVPCSecurityGroupViolation' 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:
--
-- 'violationTargetDescription', 'awsVPCSecurityGroupViolation_violationTargetDescription' - A description of the security group that violates the policy.
--
-- 'possibleSecurityGroupRemediationActions', 'awsVPCSecurityGroupViolation_possibleSecurityGroupRemediationActions' - Remediation options for the rule specified in the @ViolationTarget@.
--
-- 'violationTarget', 'awsVPCSecurityGroupViolation_violationTarget' - The security group rule that is being evaluated.
--
-- 'partialMatches', 'awsVPCSecurityGroupViolation_partialMatches' - List of rules specified in the security group of the Firewall Manager
-- policy that partially match the @ViolationTarget@ rule.
newAwsVPCSecurityGroupViolation ::
  AwsVPCSecurityGroupViolation
newAwsVPCSecurityGroupViolation :: AwsVPCSecurityGroupViolation
newAwsVPCSecurityGroupViolation =
  AwsVPCSecurityGroupViolation' :: Maybe Text
-> Maybe [SecurityGroupRemediationAction]
-> Maybe Text
-> Maybe [PartialMatch]
-> AwsVPCSecurityGroupViolation
AwsVPCSecurityGroupViolation'
    { $sel:violationTargetDescription:AwsVPCSecurityGroupViolation' :: Maybe Text
violationTargetDescription =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:possibleSecurityGroupRemediationActions:AwsVPCSecurityGroupViolation' :: Maybe [SecurityGroupRemediationAction]
possibleSecurityGroupRemediationActions =
        Maybe [SecurityGroupRemediationAction]
forall a. Maybe a
Prelude.Nothing,
      $sel:violationTarget:AwsVPCSecurityGroupViolation' :: Maybe Text
violationTarget = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:partialMatches:AwsVPCSecurityGroupViolation' :: Maybe [PartialMatch]
partialMatches = Maybe [PartialMatch]
forall a. Maybe a
Prelude.Nothing
    }

-- | A description of the security group that violates the policy.
awsVPCSecurityGroupViolation_violationTargetDescription :: Lens.Lens' AwsVPCSecurityGroupViolation (Prelude.Maybe Prelude.Text)
awsVPCSecurityGroupViolation_violationTargetDescription :: (Maybe Text -> f (Maybe Text))
-> AwsVPCSecurityGroupViolation -> f AwsVPCSecurityGroupViolation
awsVPCSecurityGroupViolation_violationTargetDescription = (AwsVPCSecurityGroupViolation -> Maybe Text)
-> (AwsVPCSecurityGroupViolation
    -> Maybe Text -> AwsVPCSecurityGroupViolation)
-> Lens
     AwsVPCSecurityGroupViolation
     AwsVPCSecurityGroupViolation
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsVPCSecurityGroupViolation' {Maybe Text
violationTargetDescription :: Maybe Text
$sel:violationTargetDescription:AwsVPCSecurityGroupViolation' :: AwsVPCSecurityGroupViolation -> Maybe Text
violationTargetDescription} -> Maybe Text
violationTargetDescription) (\s :: AwsVPCSecurityGroupViolation
s@AwsVPCSecurityGroupViolation' {} Maybe Text
a -> AwsVPCSecurityGroupViolation
s {$sel:violationTargetDescription:AwsVPCSecurityGroupViolation' :: Maybe Text
violationTargetDescription = Maybe Text
a} :: AwsVPCSecurityGroupViolation)

-- | Remediation options for the rule specified in the @ViolationTarget@.
awsVPCSecurityGroupViolation_possibleSecurityGroupRemediationActions :: Lens.Lens' AwsVPCSecurityGroupViolation (Prelude.Maybe [SecurityGroupRemediationAction])
awsVPCSecurityGroupViolation_possibleSecurityGroupRemediationActions :: (Maybe [SecurityGroupRemediationAction]
 -> f (Maybe [SecurityGroupRemediationAction]))
-> AwsVPCSecurityGroupViolation -> f AwsVPCSecurityGroupViolation
awsVPCSecurityGroupViolation_possibleSecurityGroupRemediationActions = (AwsVPCSecurityGroupViolation
 -> Maybe [SecurityGroupRemediationAction])
-> (AwsVPCSecurityGroupViolation
    -> Maybe [SecurityGroupRemediationAction]
    -> AwsVPCSecurityGroupViolation)
-> Lens
     AwsVPCSecurityGroupViolation
     AwsVPCSecurityGroupViolation
     (Maybe [SecurityGroupRemediationAction])
     (Maybe [SecurityGroupRemediationAction])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsVPCSecurityGroupViolation' {Maybe [SecurityGroupRemediationAction]
possibleSecurityGroupRemediationActions :: Maybe [SecurityGroupRemediationAction]
$sel:possibleSecurityGroupRemediationActions:AwsVPCSecurityGroupViolation' :: AwsVPCSecurityGroupViolation
-> Maybe [SecurityGroupRemediationAction]
possibleSecurityGroupRemediationActions} -> Maybe [SecurityGroupRemediationAction]
possibleSecurityGroupRemediationActions) (\s :: AwsVPCSecurityGroupViolation
s@AwsVPCSecurityGroupViolation' {} Maybe [SecurityGroupRemediationAction]
a -> AwsVPCSecurityGroupViolation
s {$sel:possibleSecurityGroupRemediationActions:AwsVPCSecurityGroupViolation' :: Maybe [SecurityGroupRemediationAction]
possibleSecurityGroupRemediationActions = Maybe [SecurityGroupRemediationAction]
a} :: AwsVPCSecurityGroupViolation) ((Maybe [SecurityGroupRemediationAction]
  -> f (Maybe [SecurityGroupRemediationAction]))
 -> AwsVPCSecurityGroupViolation -> f AwsVPCSecurityGroupViolation)
-> ((Maybe [SecurityGroupRemediationAction]
     -> f (Maybe [SecurityGroupRemediationAction]))
    -> Maybe [SecurityGroupRemediationAction]
    -> f (Maybe [SecurityGroupRemediationAction]))
-> (Maybe [SecurityGroupRemediationAction]
    -> f (Maybe [SecurityGroupRemediationAction]))
-> AwsVPCSecurityGroupViolation
-> f AwsVPCSecurityGroupViolation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SecurityGroupRemediationAction]
  [SecurityGroupRemediationAction]
  [SecurityGroupRemediationAction]
  [SecurityGroupRemediationAction]
-> Iso
     (Maybe [SecurityGroupRemediationAction])
     (Maybe [SecurityGroupRemediationAction])
     (Maybe [SecurityGroupRemediationAction])
     (Maybe [SecurityGroupRemediationAction])
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
  [SecurityGroupRemediationAction]
  [SecurityGroupRemediationAction]
  [SecurityGroupRemediationAction]
  [SecurityGroupRemediationAction]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The security group rule that is being evaluated.
awsVPCSecurityGroupViolation_violationTarget :: Lens.Lens' AwsVPCSecurityGroupViolation (Prelude.Maybe Prelude.Text)
awsVPCSecurityGroupViolation_violationTarget :: (Maybe Text -> f (Maybe Text))
-> AwsVPCSecurityGroupViolation -> f AwsVPCSecurityGroupViolation
awsVPCSecurityGroupViolation_violationTarget = (AwsVPCSecurityGroupViolation -> Maybe Text)
-> (AwsVPCSecurityGroupViolation
    -> Maybe Text -> AwsVPCSecurityGroupViolation)
-> Lens
     AwsVPCSecurityGroupViolation
     AwsVPCSecurityGroupViolation
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsVPCSecurityGroupViolation' {Maybe Text
violationTarget :: Maybe Text
$sel:violationTarget:AwsVPCSecurityGroupViolation' :: AwsVPCSecurityGroupViolation -> Maybe Text
violationTarget} -> Maybe Text
violationTarget) (\s :: AwsVPCSecurityGroupViolation
s@AwsVPCSecurityGroupViolation' {} Maybe Text
a -> AwsVPCSecurityGroupViolation
s {$sel:violationTarget:AwsVPCSecurityGroupViolation' :: Maybe Text
violationTarget = Maybe Text
a} :: AwsVPCSecurityGroupViolation)

-- | List of rules specified in the security group of the Firewall Manager
-- policy that partially match the @ViolationTarget@ rule.
awsVPCSecurityGroupViolation_partialMatches :: Lens.Lens' AwsVPCSecurityGroupViolation (Prelude.Maybe [PartialMatch])
awsVPCSecurityGroupViolation_partialMatches :: (Maybe [PartialMatch] -> f (Maybe [PartialMatch]))
-> AwsVPCSecurityGroupViolation -> f AwsVPCSecurityGroupViolation
awsVPCSecurityGroupViolation_partialMatches = (AwsVPCSecurityGroupViolation -> Maybe [PartialMatch])
-> (AwsVPCSecurityGroupViolation
    -> Maybe [PartialMatch] -> AwsVPCSecurityGroupViolation)
-> Lens
     AwsVPCSecurityGroupViolation
     AwsVPCSecurityGroupViolation
     (Maybe [PartialMatch])
     (Maybe [PartialMatch])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsVPCSecurityGroupViolation' {Maybe [PartialMatch]
partialMatches :: Maybe [PartialMatch]
$sel:partialMatches:AwsVPCSecurityGroupViolation' :: AwsVPCSecurityGroupViolation -> Maybe [PartialMatch]
partialMatches} -> Maybe [PartialMatch]
partialMatches) (\s :: AwsVPCSecurityGroupViolation
s@AwsVPCSecurityGroupViolation' {} Maybe [PartialMatch]
a -> AwsVPCSecurityGroupViolation
s {$sel:partialMatches:AwsVPCSecurityGroupViolation' :: Maybe [PartialMatch]
partialMatches = Maybe [PartialMatch]
a} :: AwsVPCSecurityGroupViolation) ((Maybe [PartialMatch] -> f (Maybe [PartialMatch]))
 -> AwsVPCSecurityGroupViolation -> f AwsVPCSecurityGroupViolation)
-> ((Maybe [PartialMatch] -> f (Maybe [PartialMatch]))
    -> Maybe [PartialMatch] -> f (Maybe [PartialMatch]))
-> (Maybe [PartialMatch] -> f (Maybe [PartialMatch]))
-> AwsVPCSecurityGroupViolation
-> f AwsVPCSecurityGroupViolation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [PartialMatch] [PartialMatch] [PartialMatch] [PartialMatch]
-> Iso
     (Maybe [PartialMatch])
     (Maybe [PartialMatch])
     (Maybe [PartialMatch])
     (Maybe [PartialMatch])
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 [PartialMatch] [PartialMatch] [PartialMatch] [PartialMatch]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AwsVPCSecurityGroupViolation where
  parseJSON :: Value -> Parser AwsVPCSecurityGroupViolation
parseJSON =
    String
-> (Object -> Parser AwsVPCSecurityGroupViolation)
-> Value
-> Parser AwsVPCSecurityGroupViolation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsVPCSecurityGroupViolation"
      ( \Object
x ->
          Maybe Text
-> Maybe [SecurityGroupRemediationAction]
-> Maybe Text
-> Maybe [PartialMatch]
-> AwsVPCSecurityGroupViolation
AwsVPCSecurityGroupViolation'
            (Maybe Text
 -> Maybe [SecurityGroupRemediationAction]
 -> Maybe Text
 -> Maybe [PartialMatch]
 -> AwsVPCSecurityGroupViolation)
-> Parser (Maybe Text)
-> Parser
     (Maybe [SecurityGroupRemediationAction]
      -> Maybe Text
      -> Maybe [PartialMatch]
      -> AwsVPCSecurityGroupViolation)
forall (f :: * -> *) a b. Functor 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
"ViolationTargetDescription")
            Parser
  (Maybe [SecurityGroupRemediationAction]
   -> Maybe Text
   -> Maybe [PartialMatch]
   -> AwsVPCSecurityGroupViolation)
-> Parser (Maybe [SecurityGroupRemediationAction])
-> Parser
     (Maybe Text
      -> Maybe [PartialMatch] -> AwsVPCSecurityGroupViolation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [SecurityGroupRemediationAction]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PossibleSecurityGroupRemediationActions"
                            Parser (Maybe (Maybe [SecurityGroupRemediationAction]))
-> Maybe [SecurityGroupRemediationAction]
-> Parser (Maybe [SecurityGroupRemediationAction])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [SecurityGroupRemediationAction]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Text
   -> Maybe [PartialMatch] -> AwsVPCSecurityGroupViolation)
-> Parser (Maybe Text)
-> Parser (Maybe [PartialMatch] -> AwsVPCSecurityGroupViolation)
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
"ViolationTarget")
            Parser (Maybe [PartialMatch] -> AwsVPCSecurityGroupViolation)
-> Parser (Maybe [PartialMatch])
-> Parser AwsVPCSecurityGroupViolation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [PartialMatch]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PartialMatches"
                            Parser (Maybe (Maybe [PartialMatch]))
-> Maybe [PartialMatch] -> Parser (Maybe [PartialMatch])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [PartialMatch]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance
  Prelude.Hashable
    AwsVPCSecurityGroupViolation

instance Prelude.NFData AwsVPCSecurityGroupViolation