{-# 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.DevOpsGuru.Types.NotificationFilterConfig
-- 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.DevOpsGuru.Types.NotificationFilterConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DevOpsGuru.Types.InsightSeverity
import Amazonka.DevOpsGuru.Types.NotificationMessageType
import qualified Amazonka.Prelude as Prelude

-- | The filter configurations for the Amazon SNS notification topic you use
-- with DevOps Guru. You can choose to specify which events or message
-- types to receive notifications for. You can also choose to specify which
-- severity levels to receive notifications for.
--
-- /See:/ 'newNotificationFilterConfig' smart constructor.
data NotificationFilterConfig = NotificationFilterConfig'
  { -- | The events that you want to receive notifications for. For example, you
    -- can choose to receive notifications only when the severity level is
    -- upgraded or a new insight is created.
    NotificationFilterConfig -> Maybe [NotificationMessageType]
messageTypes :: Prelude.Maybe [NotificationMessageType],
    -- | The severity levels that you want to receive notifications for. For
    -- example, you can choose to receive notifications only for insights with
    -- @HIGH@ and @MEDIUM@ severity levels. For more information, see
    -- <https://docs.aws.amazon.com/devops-guru/latest/userguide/working-with-insights.html#understanding-insights-severities Understanding insight severities>.
    NotificationFilterConfig -> Maybe [InsightSeverity]
severities :: Prelude.Maybe [InsightSeverity]
  }
  deriving (NotificationFilterConfig -> NotificationFilterConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotificationFilterConfig -> NotificationFilterConfig -> Bool
$c/= :: NotificationFilterConfig -> NotificationFilterConfig -> Bool
== :: NotificationFilterConfig -> NotificationFilterConfig -> Bool
$c== :: NotificationFilterConfig -> NotificationFilterConfig -> Bool
Prelude.Eq, ReadPrec [NotificationFilterConfig]
ReadPrec NotificationFilterConfig
Int -> ReadS NotificationFilterConfig
ReadS [NotificationFilterConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotificationFilterConfig]
$creadListPrec :: ReadPrec [NotificationFilterConfig]
readPrec :: ReadPrec NotificationFilterConfig
$creadPrec :: ReadPrec NotificationFilterConfig
readList :: ReadS [NotificationFilterConfig]
$creadList :: ReadS [NotificationFilterConfig]
readsPrec :: Int -> ReadS NotificationFilterConfig
$creadsPrec :: Int -> ReadS NotificationFilterConfig
Prelude.Read, Int -> NotificationFilterConfig -> ShowS
[NotificationFilterConfig] -> ShowS
NotificationFilterConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotificationFilterConfig] -> ShowS
$cshowList :: [NotificationFilterConfig] -> ShowS
show :: NotificationFilterConfig -> String
$cshow :: NotificationFilterConfig -> String
showsPrec :: Int -> NotificationFilterConfig -> ShowS
$cshowsPrec :: Int -> NotificationFilterConfig -> ShowS
Prelude.Show, forall x.
Rep NotificationFilterConfig x -> NotificationFilterConfig
forall x.
NotificationFilterConfig -> Rep NotificationFilterConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NotificationFilterConfig x -> NotificationFilterConfig
$cfrom :: forall x.
NotificationFilterConfig -> Rep NotificationFilterConfig x
Prelude.Generic)

-- |
-- Create a value of 'NotificationFilterConfig' 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:
--
-- 'messageTypes', 'notificationFilterConfig_messageTypes' - The events that you want to receive notifications for. For example, you
-- can choose to receive notifications only when the severity level is
-- upgraded or a new insight is created.
--
-- 'severities', 'notificationFilterConfig_severities' - The severity levels that you want to receive notifications for. For
-- example, you can choose to receive notifications only for insights with
-- @HIGH@ and @MEDIUM@ severity levels. For more information, see
-- <https://docs.aws.amazon.com/devops-guru/latest/userguide/working-with-insights.html#understanding-insights-severities Understanding insight severities>.
newNotificationFilterConfig ::
  NotificationFilterConfig
newNotificationFilterConfig :: NotificationFilterConfig
newNotificationFilterConfig =
  NotificationFilterConfig'
    { $sel:messageTypes:NotificationFilterConfig' :: Maybe [NotificationMessageType]
messageTypes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:severities:NotificationFilterConfig' :: Maybe [InsightSeverity]
severities = forall a. Maybe a
Prelude.Nothing
    }

-- | The events that you want to receive notifications for. For example, you
-- can choose to receive notifications only when the severity level is
-- upgraded or a new insight is created.
notificationFilterConfig_messageTypes :: Lens.Lens' NotificationFilterConfig (Prelude.Maybe [NotificationMessageType])
notificationFilterConfig_messageTypes :: Lens' NotificationFilterConfig (Maybe [NotificationMessageType])
notificationFilterConfig_messageTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationFilterConfig' {Maybe [NotificationMessageType]
messageTypes :: Maybe [NotificationMessageType]
$sel:messageTypes:NotificationFilterConfig' :: NotificationFilterConfig -> Maybe [NotificationMessageType]
messageTypes} -> Maybe [NotificationMessageType]
messageTypes) (\s :: NotificationFilterConfig
s@NotificationFilterConfig' {} Maybe [NotificationMessageType]
a -> NotificationFilterConfig
s {$sel:messageTypes:NotificationFilterConfig' :: Maybe [NotificationMessageType]
messageTypes = Maybe [NotificationMessageType]
a} :: NotificationFilterConfig) 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 severity levels that you want to receive notifications for. For
-- example, you can choose to receive notifications only for insights with
-- @HIGH@ and @MEDIUM@ severity levels. For more information, see
-- <https://docs.aws.amazon.com/devops-guru/latest/userguide/working-with-insights.html#understanding-insights-severities Understanding insight severities>.
notificationFilterConfig_severities :: Lens.Lens' NotificationFilterConfig (Prelude.Maybe [InsightSeverity])
notificationFilterConfig_severities :: Lens' NotificationFilterConfig (Maybe [InsightSeverity])
notificationFilterConfig_severities = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationFilterConfig' {Maybe [InsightSeverity]
severities :: Maybe [InsightSeverity]
$sel:severities:NotificationFilterConfig' :: NotificationFilterConfig -> Maybe [InsightSeverity]
severities} -> Maybe [InsightSeverity]
severities) (\s :: NotificationFilterConfig
s@NotificationFilterConfig' {} Maybe [InsightSeverity]
a -> NotificationFilterConfig
s {$sel:severities:NotificationFilterConfig' :: Maybe [InsightSeverity]
severities = Maybe [InsightSeverity]
a} :: NotificationFilterConfig) 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 NotificationFilterConfig where
  parseJSON :: Value -> Parser NotificationFilterConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NotificationFilterConfig"
      ( \Object
x ->
          Maybe [NotificationMessageType]
-> Maybe [InsightSeverity] -> NotificationFilterConfig
NotificationFilterConfig'
            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
"MessageTypes" 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 (Maybe a)
Data..:? Key
"Severities" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable NotificationFilterConfig where
  hashWithSalt :: Int -> NotificationFilterConfig -> Int
hashWithSalt Int
_salt NotificationFilterConfig' {Maybe [InsightSeverity]
Maybe [NotificationMessageType]
severities :: Maybe [InsightSeverity]
messageTypes :: Maybe [NotificationMessageType]
$sel:severities:NotificationFilterConfig' :: NotificationFilterConfig -> Maybe [InsightSeverity]
$sel:messageTypes:NotificationFilterConfig' :: NotificationFilterConfig -> Maybe [NotificationMessageType]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [NotificationMessageType]
messageTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [InsightSeverity]
severities

instance Prelude.NFData NotificationFilterConfig where
  rnf :: NotificationFilterConfig -> ()
rnf NotificationFilterConfig' {Maybe [InsightSeverity]
Maybe [NotificationMessageType]
severities :: Maybe [InsightSeverity]
messageTypes :: Maybe [NotificationMessageType]
$sel:severities:NotificationFilterConfig' :: NotificationFilterConfig -> Maybe [InsightSeverity]
$sel:messageTypes:NotificationFilterConfig' :: NotificationFilterConfig -> Maybe [NotificationMessageType]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [NotificationMessageType]
messageTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [InsightSeverity]
severities

instance Data.ToJSON NotificationFilterConfig where
  toJSON :: NotificationFilterConfig -> Value
toJSON NotificationFilterConfig' {Maybe [InsightSeverity]
Maybe [NotificationMessageType]
severities :: Maybe [InsightSeverity]
messageTypes :: Maybe [NotificationMessageType]
$sel:severities:NotificationFilterConfig' :: NotificationFilterConfig -> Maybe [InsightSeverity]
$sel:messageTypes:NotificationFilterConfig' :: NotificationFilterConfig -> Maybe [NotificationMessageType]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MessageTypes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [NotificationMessageType]
messageTypes,
            (Key
"Severities" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [InsightSeverity]
severities
          ]
      )