{-# 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.WorkMail.Types.ImpersonationMatchedRule
-- 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.WorkMail.Types.ImpersonationMatchedRule 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 impersonation rule that matched the input.
--
-- /See:/ 'newImpersonationMatchedRule' smart constructor.
data ImpersonationMatchedRule = ImpersonationMatchedRule'
  { -- | The ID of the rule that matched the input
    ImpersonationMatchedRule -> Maybe Text
impersonationRuleId :: Prelude.Maybe Prelude.Text,
    -- | The name of the rule that matched the input.
    ImpersonationMatchedRule -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ImpersonationMatchedRule -> ImpersonationMatchedRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImpersonationMatchedRule -> ImpersonationMatchedRule -> Bool
$c/= :: ImpersonationMatchedRule -> ImpersonationMatchedRule -> Bool
== :: ImpersonationMatchedRule -> ImpersonationMatchedRule -> Bool
$c== :: ImpersonationMatchedRule -> ImpersonationMatchedRule -> Bool
Prelude.Eq, ReadPrec [ImpersonationMatchedRule]
ReadPrec ImpersonationMatchedRule
Int -> ReadS ImpersonationMatchedRule
ReadS [ImpersonationMatchedRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImpersonationMatchedRule]
$creadListPrec :: ReadPrec [ImpersonationMatchedRule]
readPrec :: ReadPrec ImpersonationMatchedRule
$creadPrec :: ReadPrec ImpersonationMatchedRule
readList :: ReadS [ImpersonationMatchedRule]
$creadList :: ReadS [ImpersonationMatchedRule]
readsPrec :: Int -> ReadS ImpersonationMatchedRule
$creadsPrec :: Int -> ReadS ImpersonationMatchedRule
Prelude.Read, Int -> ImpersonationMatchedRule -> ShowS
[ImpersonationMatchedRule] -> ShowS
ImpersonationMatchedRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImpersonationMatchedRule] -> ShowS
$cshowList :: [ImpersonationMatchedRule] -> ShowS
show :: ImpersonationMatchedRule -> String
$cshow :: ImpersonationMatchedRule -> String
showsPrec :: Int -> ImpersonationMatchedRule -> ShowS
$cshowsPrec :: Int -> ImpersonationMatchedRule -> ShowS
Prelude.Show, forall x.
Rep ImpersonationMatchedRule x -> ImpersonationMatchedRule
forall x.
ImpersonationMatchedRule -> Rep ImpersonationMatchedRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ImpersonationMatchedRule x -> ImpersonationMatchedRule
$cfrom :: forall x.
ImpersonationMatchedRule -> Rep ImpersonationMatchedRule x
Prelude.Generic)

-- |
-- Create a value of 'ImpersonationMatchedRule' 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:
--
-- 'impersonationRuleId', 'impersonationMatchedRule_impersonationRuleId' - The ID of the rule that matched the input
--
-- 'name', 'impersonationMatchedRule_name' - The name of the rule that matched the input.
newImpersonationMatchedRule ::
  ImpersonationMatchedRule
newImpersonationMatchedRule :: ImpersonationMatchedRule
newImpersonationMatchedRule =
  ImpersonationMatchedRule'
    { $sel:impersonationRuleId:ImpersonationMatchedRule' :: Maybe Text
impersonationRuleId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:ImpersonationMatchedRule' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the rule that matched the input
impersonationMatchedRule_impersonationRuleId :: Lens.Lens' ImpersonationMatchedRule (Prelude.Maybe Prelude.Text)
impersonationMatchedRule_impersonationRuleId :: Lens' ImpersonationMatchedRule (Maybe Text)
impersonationMatchedRule_impersonationRuleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationMatchedRule' {Maybe Text
impersonationRuleId :: Maybe Text
$sel:impersonationRuleId:ImpersonationMatchedRule' :: ImpersonationMatchedRule -> Maybe Text
impersonationRuleId} -> Maybe Text
impersonationRuleId) (\s :: ImpersonationMatchedRule
s@ImpersonationMatchedRule' {} Maybe Text
a -> ImpersonationMatchedRule
s {$sel:impersonationRuleId:ImpersonationMatchedRule' :: Maybe Text
impersonationRuleId = Maybe Text
a} :: ImpersonationMatchedRule)

-- | The name of the rule that matched the input.
impersonationMatchedRule_name :: Lens.Lens' ImpersonationMatchedRule (Prelude.Maybe Prelude.Text)
impersonationMatchedRule_name :: Lens' ImpersonationMatchedRule (Maybe Text)
impersonationMatchedRule_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationMatchedRule' {Maybe Text
name :: Maybe Text
$sel:name:ImpersonationMatchedRule' :: ImpersonationMatchedRule -> Maybe Text
name} -> Maybe Text
name) (\s :: ImpersonationMatchedRule
s@ImpersonationMatchedRule' {} Maybe Text
a -> ImpersonationMatchedRule
s {$sel:name:ImpersonationMatchedRule' :: Maybe Text
name = Maybe Text
a} :: ImpersonationMatchedRule)

instance Data.FromJSON ImpersonationMatchedRule where
  parseJSON :: Value -> Parser ImpersonationMatchedRule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ImpersonationMatchedRule"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ImpersonationMatchedRule
ImpersonationMatchedRule'
            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
"ImpersonationRuleId")
            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
"Name")
      )

instance Prelude.Hashable ImpersonationMatchedRule where
  hashWithSalt :: Int -> ImpersonationMatchedRule -> Int
hashWithSalt Int
_salt ImpersonationMatchedRule' {Maybe Text
name :: Maybe Text
impersonationRuleId :: Maybe Text
$sel:name:ImpersonationMatchedRule' :: ImpersonationMatchedRule -> Maybe Text
$sel:impersonationRuleId:ImpersonationMatchedRule' :: ImpersonationMatchedRule -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
impersonationRuleId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData ImpersonationMatchedRule where
  rnf :: ImpersonationMatchedRule -> ()
rnf ImpersonationMatchedRule' {Maybe Text
name :: Maybe Text
impersonationRuleId :: Maybe Text
$sel:name:ImpersonationMatchedRule' :: ImpersonationMatchedRule -> Maybe Text
$sel:impersonationRuleId:ImpersonationMatchedRule' :: ImpersonationMatchedRule -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
impersonationRuleId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name