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

import qualified Amazonka.Core as Core
import Amazonka.FMS.Types.ResourceViolation
import Amazonka.FMS.Types.Tag
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Violations for a resource based on the specified Firewall Manager policy
-- and Amazon Web Services account.
--
-- /See:/ 'newViolationDetail' smart constructor.
data ViolationDetail = ViolationDetail'
  { -- | The @ResourceTag@ objects associated with the resource.
    ViolationDetail -> Maybe [Tag]
resourceTags :: Prelude.Maybe [Tag],
    -- | Brief description for the requested resource.
    ViolationDetail -> Maybe Text
resourceDescription :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Firewall Manager policy that the violation details were
    -- requested for.
    ViolationDetail -> Text
policyId :: Prelude.Text,
    -- | The Amazon Web Services account that the violation details were
    -- requested for.
    ViolationDetail -> Text
memberAccount :: Prelude.Text,
    -- | The resource ID that the violation details were requested for.
    ViolationDetail -> Text
resourceId :: Prelude.Text,
    -- | The resource type that the violation details were requested for.
    ViolationDetail -> Text
resourceType :: Prelude.Text,
    -- | List of violations for the requested resource.
    ViolationDetail -> [ResourceViolation]
resourceViolations :: [ResourceViolation]
  }
  deriving (ViolationDetail -> ViolationDetail -> Bool
(ViolationDetail -> ViolationDetail -> Bool)
-> (ViolationDetail -> ViolationDetail -> Bool)
-> Eq ViolationDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ViolationDetail -> ViolationDetail -> Bool
$c/= :: ViolationDetail -> ViolationDetail -> Bool
== :: ViolationDetail -> ViolationDetail -> Bool
$c== :: ViolationDetail -> ViolationDetail -> Bool
Prelude.Eq, ReadPrec [ViolationDetail]
ReadPrec ViolationDetail
Int -> ReadS ViolationDetail
ReadS [ViolationDetail]
(Int -> ReadS ViolationDetail)
-> ReadS [ViolationDetail]
-> ReadPrec ViolationDetail
-> ReadPrec [ViolationDetail]
-> Read ViolationDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ViolationDetail]
$creadListPrec :: ReadPrec [ViolationDetail]
readPrec :: ReadPrec ViolationDetail
$creadPrec :: ReadPrec ViolationDetail
readList :: ReadS [ViolationDetail]
$creadList :: ReadS [ViolationDetail]
readsPrec :: Int -> ReadS ViolationDetail
$creadsPrec :: Int -> ReadS ViolationDetail
Prelude.Read, Int -> ViolationDetail -> ShowS
[ViolationDetail] -> ShowS
ViolationDetail -> String
(Int -> ViolationDetail -> ShowS)
-> (ViolationDetail -> String)
-> ([ViolationDetail] -> ShowS)
-> Show ViolationDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ViolationDetail] -> ShowS
$cshowList :: [ViolationDetail] -> ShowS
show :: ViolationDetail -> String
$cshow :: ViolationDetail -> String
showsPrec :: Int -> ViolationDetail -> ShowS
$cshowsPrec :: Int -> ViolationDetail -> ShowS
Prelude.Show, (forall x. ViolationDetail -> Rep ViolationDetail x)
-> (forall x. Rep ViolationDetail x -> ViolationDetail)
-> Generic ViolationDetail
forall x. Rep ViolationDetail x -> ViolationDetail
forall x. ViolationDetail -> Rep ViolationDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ViolationDetail x -> ViolationDetail
$cfrom :: forall x. ViolationDetail -> Rep ViolationDetail x
Prelude.Generic)

-- |
-- Create a value of 'ViolationDetail' 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:
--
-- 'resourceTags', 'violationDetail_resourceTags' - The @ResourceTag@ objects associated with the resource.
--
-- 'resourceDescription', 'violationDetail_resourceDescription' - Brief description for the requested resource.
--
-- 'policyId', 'violationDetail_policyId' - The ID of the Firewall Manager policy that the violation details were
-- requested for.
--
-- 'memberAccount', 'violationDetail_memberAccount' - The Amazon Web Services account that the violation details were
-- requested for.
--
-- 'resourceId', 'violationDetail_resourceId' - The resource ID that the violation details were requested for.
--
-- 'resourceType', 'violationDetail_resourceType' - The resource type that the violation details were requested for.
--
-- 'resourceViolations', 'violationDetail_resourceViolations' - List of violations for the requested resource.
newViolationDetail ::
  -- | 'policyId'
  Prelude.Text ->
  -- | 'memberAccount'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'resourceType'
  Prelude.Text ->
  ViolationDetail
newViolationDetail :: Text -> Text -> Text -> Text -> ViolationDetail
newViolationDetail
  Text
pPolicyId_
  Text
pMemberAccount_
  Text
pResourceId_
  Text
pResourceType_ =
    ViolationDetail' :: Maybe [Tag]
-> Maybe Text
-> Text
-> Text
-> Text
-> Text
-> [ResourceViolation]
-> ViolationDetail
ViolationDetail'
      { $sel:resourceTags:ViolationDetail' :: Maybe [Tag]
resourceTags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:resourceDescription:ViolationDetail' :: Maybe Text
resourceDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:policyId:ViolationDetail' :: Text
policyId = Text
pPolicyId_,
        $sel:memberAccount:ViolationDetail' :: Text
memberAccount = Text
pMemberAccount_,
        $sel:resourceId:ViolationDetail' :: Text
resourceId = Text
pResourceId_,
        $sel:resourceType:ViolationDetail' :: Text
resourceType = Text
pResourceType_,
        $sel:resourceViolations:ViolationDetail' :: [ResourceViolation]
resourceViolations = [ResourceViolation]
forall a. Monoid a => a
Prelude.mempty
      }

-- | The @ResourceTag@ objects associated with the resource.
violationDetail_resourceTags :: Lens.Lens' ViolationDetail (Prelude.Maybe [Tag])
violationDetail_resourceTags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> ViolationDetail -> f ViolationDetail
violationDetail_resourceTags = (ViolationDetail -> Maybe [Tag])
-> (ViolationDetail -> Maybe [Tag] -> ViolationDetail)
-> Lens ViolationDetail ViolationDetail (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ViolationDetail' {Maybe [Tag]
resourceTags :: Maybe [Tag]
$sel:resourceTags:ViolationDetail' :: ViolationDetail -> Maybe [Tag]
resourceTags} -> Maybe [Tag]
resourceTags) (\s :: ViolationDetail
s@ViolationDetail' {} Maybe [Tag]
a -> ViolationDetail
s {$sel:resourceTags:ViolationDetail' :: Maybe [Tag]
resourceTags = Maybe [Tag]
a} :: ViolationDetail) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> ViolationDetail -> f ViolationDetail)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> ViolationDetail
-> f ViolationDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Brief description for the requested resource.
violationDetail_resourceDescription :: Lens.Lens' ViolationDetail (Prelude.Maybe Prelude.Text)
violationDetail_resourceDescription :: (Maybe Text -> f (Maybe Text))
-> ViolationDetail -> f ViolationDetail
violationDetail_resourceDescription = (ViolationDetail -> Maybe Text)
-> (ViolationDetail -> Maybe Text -> ViolationDetail)
-> Lens ViolationDetail ViolationDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ViolationDetail' {Maybe Text
resourceDescription :: Maybe Text
$sel:resourceDescription:ViolationDetail' :: ViolationDetail -> Maybe Text
resourceDescription} -> Maybe Text
resourceDescription) (\s :: ViolationDetail
s@ViolationDetail' {} Maybe Text
a -> ViolationDetail
s {$sel:resourceDescription:ViolationDetail' :: Maybe Text
resourceDescription = Maybe Text
a} :: ViolationDetail)

-- | The ID of the Firewall Manager policy that the violation details were
-- requested for.
violationDetail_policyId :: Lens.Lens' ViolationDetail Prelude.Text
violationDetail_policyId :: (Text -> f Text) -> ViolationDetail -> f ViolationDetail
violationDetail_policyId = (ViolationDetail -> Text)
-> (ViolationDetail -> Text -> ViolationDetail)
-> Lens ViolationDetail ViolationDetail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ViolationDetail' {Text
policyId :: Text
$sel:policyId:ViolationDetail' :: ViolationDetail -> Text
policyId} -> Text
policyId) (\s :: ViolationDetail
s@ViolationDetail' {} Text
a -> ViolationDetail
s {$sel:policyId:ViolationDetail' :: Text
policyId = Text
a} :: ViolationDetail)

-- | The Amazon Web Services account that the violation details were
-- requested for.
violationDetail_memberAccount :: Lens.Lens' ViolationDetail Prelude.Text
violationDetail_memberAccount :: (Text -> f Text) -> ViolationDetail -> f ViolationDetail
violationDetail_memberAccount = (ViolationDetail -> Text)
-> (ViolationDetail -> Text -> ViolationDetail)
-> Lens ViolationDetail ViolationDetail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ViolationDetail' {Text
memberAccount :: Text
$sel:memberAccount:ViolationDetail' :: ViolationDetail -> Text
memberAccount} -> Text
memberAccount) (\s :: ViolationDetail
s@ViolationDetail' {} Text
a -> ViolationDetail
s {$sel:memberAccount:ViolationDetail' :: Text
memberAccount = Text
a} :: ViolationDetail)

-- | The resource ID that the violation details were requested for.
violationDetail_resourceId :: Lens.Lens' ViolationDetail Prelude.Text
violationDetail_resourceId :: (Text -> f Text) -> ViolationDetail -> f ViolationDetail
violationDetail_resourceId = (ViolationDetail -> Text)
-> (ViolationDetail -> Text -> ViolationDetail)
-> Lens ViolationDetail ViolationDetail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ViolationDetail' {Text
resourceId :: Text
$sel:resourceId:ViolationDetail' :: ViolationDetail -> Text
resourceId} -> Text
resourceId) (\s :: ViolationDetail
s@ViolationDetail' {} Text
a -> ViolationDetail
s {$sel:resourceId:ViolationDetail' :: Text
resourceId = Text
a} :: ViolationDetail)

-- | The resource type that the violation details were requested for.
violationDetail_resourceType :: Lens.Lens' ViolationDetail Prelude.Text
violationDetail_resourceType :: (Text -> f Text) -> ViolationDetail -> f ViolationDetail
violationDetail_resourceType = (ViolationDetail -> Text)
-> (ViolationDetail -> Text -> ViolationDetail)
-> Lens ViolationDetail ViolationDetail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ViolationDetail' {Text
resourceType :: Text
$sel:resourceType:ViolationDetail' :: ViolationDetail -> Text
resourceType} -> Text
resourceType) (\s :: ViolationDetail
s@ViolationDetail' {} Text
a -> ViolationDetail
s {$sel:resourceType:ViolationDetail' :: Text
resourceType = Text
a} :: ViolationDetail)

-- | List of violations for the requested resource.
violationDetail_resourceViolations :: Lens.Lens' ViolationDetail [ResourceViolation]
violationDetail_resourceViolations :: ([ResourceViolation] -> f [ResourceViolation])
-> ViolationDetail -> f ViolationDetail
violationDetail_resourceViolations = (ViolationDetail -> [ResourceViolation])
-> (ViolationDetail -> [ResourceViolation] -> ViolationDetail)
-> Lens
     ViolationDetail
     ViolationDetail
     [ResourceViolation]
     [ResourceViolation]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ViolationDetail' {[ResourceViolation]
resourceViolations :: [ResourceViolation]
$sel:resourceViolations:ViolationDetail' :: ViolationDetail -> [ResourceViolation]
resourceViolations} -> [ResourceViolation]
resourceViolations) (\s :: ViolationDetail
s@ViolationDetail' {} [ResourceViolation]
a -> ViolationDetail
s {$sel:resourceViolations:ViolationDetail' :: [ResourceViolation]
resourceViolations = [ResourceViolation]
a} :: ViolationDetail) (([ResourceViolation] -> f [ResourceViolation])
 -> ViolationDetail -> f ViolationDetail)
-> (([ResourceViolation] -> f [ResourceViolation])
    -> [ResourceViolation] -> f [ResourceViolation])
-> ([ResourceViolation] -> f [ResourceViolation])
-> ViolationDetail
-> f ViolationDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ResourceViolation] -> f [ResourceViolation])
-> [ResourceViolation] -> f [ResourceViolation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ViolationDetail where
  parseJSON :: Value -> Parser ViolationDetail
parseJSON =
    String
-> (Object -> Parser ViolationDetail)
-> Value
-> Parser ViolationDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ViolationDetail"
      ( \Object
x ->
          Maybe [Tag]
-> Maybe Text
-> Text
-> Text
-> Text
-> Text
-> [ResourceViolation]
-> ViolationDetail
ViolationDetail'
            (Maybe [Tag]
 -> Maybe Text
 -> Text
 -> Text
 -> Text
 -> Text
 -> [ResourceViolation]
 -> ViolationDetail)
-> Parser (Maybe [Tag])
-> Parser
     (Maybe Text
      -> Text
      -> Text
      -> Text
      -> Text
      -> [ResourceViolation]
      -> ViolationDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Tag]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceTags" Parser (Maybe (Maybe [Tag])) -> Maybe [Tag] -> Parser (Maybe [Tag])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Tag]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Text
   -> Text
   -> Text
   -> Text
   -> [ResourceViolation]
   -> ViolationDetail)
-> Parser (Maybe Text)
-> Parser
     (Text
      -> Text -> Text -> Text -> [ResourceViolation] -> ViolationDetail)
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
"ResourceDescription")
            Parser
  (Text
   -> Text -> Text -> Text -> [ResourceViolation] -> ViolationDetail)
-> Parser Text
-> Parser
     (Text -> Text -> Text -> [ResourceViolation] -> ViolationDetail)
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
"PolicyId")
            Parser
  (Text -> Text -> Text -> [ResourceViolation] -> ViolationDetail)
-> Parser Text
-> Parser (Text -> Text -> [ResourceViolation] -> ViolationDetail)
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
"MemberAccount")
            Parser (Text -> Text -> [ResourceViolation] -> ViolationDetail)
-> Parser Text
-> Parser (Text -> [ResourceViolation] -> ViolationDetail)
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
"ResourceId")
            Parser (Text -> [ResourceViolation] -> ViolationDetail)
-> Parser Text -> Parser ([ResourceViolation] -> ViolationDetail)
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
"ResourceType")
            Parser ([ResourceViolation] -> ViolationDetail)
-> Parser [ResourceViolation] -> Parser ViolationDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe [ResourceViolation])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceViolations"
                            Parser (Maybe [ResourceViolation])
-> [ResourceViolation] -> Parser [ResourceViolation]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [ResourceViolation]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ViolationDetail

instance Prelude.NFData ViolationDetail