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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types.ResourceViolation
import Amazonka.FMS.Types.Tag
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'
  { -- | Brief description for the requested resource.
    ViolationDetail -> Maybe Text
resourceDescription :: Prelude.Maybe Prelude.Text,
    -- | The @ResourceTag@ objects associated with the resource.
    ViolationDetail -> Maybe [Tag]
resourceTags :: Prelude.Maybe [Tag],
    -- | 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
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]
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
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. 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:
--
-- 'resourceDescription', 'violationDetail_resourceDescription' - Brief description for the requested resource.
--
-- 'resourceTags', 'violationDetail_resourceTags' - The @ResourceTag@ objects associated with the 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'
      { $sel:resourceDescription:ViolationDetail' :: Maybe Text
resourceDescription =
          forall a. Maybe a
Prelude.Nothing,
        $sel:resourceTags:ViolationDetail' :: Maybe [Tag]
resourceTags = 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 = forall a. Monoid a => a
Prelude.mempty
      }

-- | Brief description for the requested resource.
violationDetail_resourceDescription :: Lens.Lens' ViolationDetail (Prelude.Maybe Prelude.Text)
violationDetail_resourceDescription :: Lens' ViolationDetail (Maybe Text)
violationDetail_resourceDescription = 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 @ResourceTag@ objects associated with the resource.
violationDetail_resourceTags :: Lens.Lens' ViolationDetail (Prelude.Maybe [Tag])
violationDetail_resourceTags :: Lens' ViolationDetail (Maybe [Tag])
violationDetail_resourceTags = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the Firewall Manager policy that the violation details were
-- requested for.
violationDetail_policyId :: Lens.Lens' ViolationDetail Prelude.Text
violationDetail_policyId :: Lens' ViolationDetail Text
violationDetail_policyId = 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 :: Lens' ViolationDetail Text
violationDetail_memberAccount = 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 :: Lens' ViolationDetail Text
violationDetail_resourceId = 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 :: Lens' ViolationDetail Text
violationDetail_resourceType = 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 :: Lens' ViolationDetail [ResourceViolation]
violationDetail_resourceViolations = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ViolationDetail where
  hashWithSalt :: Int -> ViolationDetail -> Int
hashWithSalt Int
_salt ViolationDetail' {[ResourceViolation]
Maybe [Tag]
Maybe Text
Text
resourceViolations :: [ResourceViolation]
resourceType :: Text
resourceId :: Text
memberAccount :: Text
policyId :: Text
resourceTags :: Maybe [Tag]
resourceDescription :: Maybe Text
$sel:resourceViolations:ViolationDetail' :: ViolationDetail -> [ResourceViolation]
$sel:resourceType:ViolationDetail' :: ViolationDetail -> Text
$sel:resourceId:ViolationDetail' :: ViolationDetail -> Text
$sel:memberAccount:ViolationDetail' :: ViolationDetail -> Text
$sel:policyId:ViolationDetail' :: ViolationDetail -> Text
$sel:resourceTags:ViolationDetail' :: ViolationDetail -> Maybe [Tag]
$sel:resourceDescription:ViolationDetail' :: ViolationDetail -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
resourceTags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
memberAccount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ResourceViolation]
resourceViolations

instance Prelude.NFData ViolationDetail where
  rnf :: ViolationDetail -> ()
rnf ViolationDetail' {[ResourceViolation]
Maybe [Tag]
Maybe Text
Text
resourceViolations :: [ResourceViolation]
resourceType :: Text
resourceId :: Text
memberAccount :: Text
policyId :: Text
resourceTags :: Maybe [Tag]
resourceDescription :: Maybe Text
$sel:resourceViolations:ViolationDetail' :: ViolationDetail -> [ResourceViolation]
$sel:resourceType:ViolationDetail' :: ViolationDetail -> Text
$sel:resourceId:ViolationDetail' :: ViolationDetail -> Text
$sel:memberAccount:ViolationDetail' :: ViolationDetail -> Text
$sel:policyId:ViolationDetail' :: ViolationDetail -> Text
$sel:resourceTags:ViolationDetail' :: ViolationDetail -> Maybe [Tag]
$sel:resourceDescription:ViolationDetail' :: ViolationDetail -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
resourceTags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
memberAccount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [ResourceViolation]
resourceViolations