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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 violation reason.
    PartialMatch -> Maybe [Text]
targetViolationReasons :: Prelude.Maybe [Prelude.Text],
    -- | The reference rule from the primary security group of the Firewall
    -- Manager policy.
    PartialMatch -> Maybe Text
reference :: Prelude.Maybe Prelude.Text
  }
  deriving (PartialMatch -> PartialMatch -> Bool
(PartialMatch -> PartialMatch -> Bool)
-> (PartialMatch -> PartialMatch -> Bool) -> Eq PartialMatch
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]
(Int -> ReadS PartialMatch)
-> ReadS [PartialMatch]
-> ReadPrec PartialMatch
-> ReadPrec [PartialMatch]
-> Read 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
(Int -> PartialMatch -> ShowS)
-> (PartialMatch -> String)
-> ([PartialMatch] -> ShowS)
-> Show PartialMatch
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. PartialMatch -> Rep PartialMatch x)
-> (forall x. Rep PartialMatch x -> PartialMatch)
-> Generic PartialMatch
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:
--
-- 'targetViolationReasons', 'partialMatch_targetViolationReasons' - The violation reason.
--
-- 'reference', 'partialMatch_reference' - The reference rule from the primary security group of the Firewall
-- Manager policy.
newPartialMatch ::
  PartialMatch
newPartialMatch :: PartialMatch
newPartialMatch =
  PartialMatch' :: Maybe [Text] -> Maybe Text -> PartialMatch
PartialMatch'
    { $sel:targetViolationReasons:PartialMatch' :: Maybe [Text]
targetViolationReasons =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:reference:PartialMatch' :: Maybe Text
reference = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The violation reason.
partialMatch_targetViolationReasons :: Lens.Lens' PartialMatch (Prelude.Maybe [Prelude.Text])
partialMatch_targetViolationReasons :: (Maybe [Text] -> f (Maybe [Text]))
-> PartialMatch -> f PartialMatch
partialMatch_targetViolationReasons = (PartialMatch -> Maybe [Text])
-> (PartialMatch -> Maybe [Text] -> PartialMatch)
-> Lens PartialMatch PartialMatch (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> PartialMatch -> f PartialMatch)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PartialMatch
-> f PartialMatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The reference rule from the primary security group of the Firewall
-- Manager policy.
partialMatch_reference :: Lens.Lens' PartialMatch (Prelude.Maybe Prelude.Text)
partialMatch_reference :: (Maybe Text -> f (Maybe Text)) -> PartialMatch -> f PartialMatch
partialMatch_reference = (PartialMatch -> Maybe Text)
-> (PartialMatch -> Maybe Text -> PartialMatch)
-> Lens PartialMatch PartialMatch (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable PartialMatch

instance Prelude.NFData PartialMatch