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

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 reference rule that partially matches the @ViolationTarget@ rule and
-- violation reason.
--
-- /See:/ 'newPartialMatch' smart constructor.
data PartialMatch = PartialMatch'
  { -- | The reference rule from the primary security group of the Firewall
    -- Manager policy.
    PartialMatch -> Maybe Text
reference :: Prelude.Maybe Prelude.Text,
    -- | The violation reason.
    PartialMatch -> Maybe [Text]
targetViolationReasons :: Prelude.Maybe [Prelude.Text]
  }
  deriving (PartialMatch -> PartialMatch -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartialMatch -> PartialMatch -> Bool
$c/= :: PartialMatch -> PartialMatch -> Bool
== :: PartialMatch -> PartialMatch -> Bool
$c== :: PartialMatch -> PartialMatch -> Bool
Prelude.Eq, ReadPrec [PartialMatch]
ReadPrec PartialMatch
Int -> ReadS PartialMatch
ReadS [PartialMatch]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartialMatch]
$creadListPrec :: ReadPrec [PartialMatch]
readPrec :: ReadPrec PartialMatch
$creadPrec :: ReadPrec PartialMatch
readList :: ReadS [PartialMatch]
$creadList :: ReadS [PartialMatch]
readsPrec :: Int -> ReadS PartialMatch
$creadsPrec :: Int -> ReadS PartialMatch
Prelude.Read, Int -> PartialMatch -> ShowS
[PartialMatch] -> ShowS
PartialMatch -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartialMatch] -> ShowS
$cshowList :: [PartialMatch] -> ShowS
show :: PartialMatch -> String
$cshow :: PartialMatch -> String
showsPrec :: Int -> PartialMatch -> ShowS
$cshowsPrec :: Int -> PartialMatch -> ShowS
Prelude.Show, forall x. Rep PartialMatch x -> PartialMatch
forall x. PartialMatch -> Rep PartialMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PartialMatch x -> PartialMatch
$cfrom :: forall x. PartialMatch -> Rep PartialMatch x
Prelude.Generic)

-- |
-- Create a value of 'PartialMatch' 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:
--
-- 'reference', 'partialMatch_reference' - The reference rule from the primary security group of the Firewall
-- Manager policy.
--
-- 'targetViolationReasons', 'partialMatch_targetViolationReasons' - The violation reason.
newPartialMatch ::
  PartialMatch
newPartialMatch :: PartialMatch
newPartialMatch =
  PartialMatch'
    { $sel:reference:PartialMatch' :: Maybe Text
reference = forall a. Maybe a
Prelude.Nothing,
      $sel:targetViolationReasons:PartialMatch' :: Maybe [Text]
targetViolationReasons = forall a. Maybe a
Prelude.Nothing
    }

-- | The reference rule from the primary security group of the Firewall
-- Manager policy.
partialMatch_reference :: Lens.Lens' PartialMatch (Prelude.Maybe Prelude.Text)
partialMatch_reference :: Lens' PartialMatch (Maybe Text)
partialMatch_reference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartialMatch' {Maybe Text
reference :: Maybe Text
$sel:reference:PartialMatch' :: PartialMatch -> Maybe Text
reference} -> Maybe Text
reference) (\s :: PartialMatch
s@PartialMatch' {} Maybe Text
a -> PartialMatch
s {$sel:reference:PartialMatch' :: Maybe Text
reference = Maybe Text
a} :: PartialMatch)

-- | The violation reason.
partialMatch_targetViolationReasons :: Lens.Lens' PartialMatch (Prelude.Maybe [Prelude.Text])
partialMatch_targetViolationReasons :: Lens' PartialMatch (Maybe [Text])
partialMatch_targetViolationReasons = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartialMatch' {Maybe [Text]
targetViolationReasons :: Maybe [Text]
$sel:targetViolationReasons:PartialMatch' :: PartialMatch -> Maybe [Text]
targetViolationReasons} -> Maybe [Text]
targetViolationReasons) (\s :: PartialMatch
s@PartialMatch' {} Maybe [Text]
a -> PartialMatch
s {$sel:targetViolationReasons:PartialMatch' :: Maybe [Text]
targetViolationReasons = Maybe [Text]
a} :: PartialMatch) 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

instance Data.FromJSON PartialMatch where
  parseJSON :: Value -> Parser PartialMatch
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PartialMatch"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> PartialMatch
PartialMatch'
            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
"Reference")
            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
"TargetViolationReasons"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable PartialMatch where
  hashWithSalt :: Int -> PartialMatch -> Int
hashWithSalt Int
_salt PartialMatch' {Maybe [Text]
Maybe Text
targetViolationReasons :: Maybe [Text]
reference :: Maybe Text
$sel:targetViolationReasons:PartialMatch' :: PartialMatch -> Maybe [Text]
$sel:reference:PartialMatch' :: PartialMatch -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
targetViolationReasons

instance Prelude.NFData PartialMatch where
  rnf :: PartialMatch -> ()
rnf PartialMatch' {Maybe [Text]
Maybe Text
targetViolationReasons :: Maybe [Text]
reference :: Maybe Text
$sel:targetViolationReasons:PartialMatch' :: PartialMatch -> Maybe [Text]
$sel:reference:PartialMatch' :: PartialMatch -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
targetViolationReasons