{-# 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.CodeGuruProfiler.Types.NotificationConfiguration
-- 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.CodeGuruProfiler.Types.NotificationConfiguration where

import Amazonka.CodeGuruProfiler.Types.Channel
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The configuration for notifications stored for each profiling group.
-- This includes up to to two channels and a list of event publishers
-- associated with each channel.
--
-- /See:/ 'newNotificationConfiguration' smart constructor.
data NotificationConfiguration = NotificationConfiguration'
  { -- | List of up to two channels to be used for sending notifications for
    -- events detected from the application profile.
    NotificationConfiguration -> Maybe (NonEmpty Channel)
channels :: Prelude.Maybe (Prelude.NonEmpty Channel)
  }
  deriving (NotificationConfiguration -> NotificationConfiguration -> Bool
(NotificationConfiguration -> NotificationConfiguration -> Bool)
-> (NotificationConfiguration -> NotificationConfiguration -> Bool)
-> Eq NotificationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotificationConfiguration -> NotificationConfiguration -> Bool
$c/= :: NotificationConfiguration -> NotificationConfiguration -> Bool
== :: NotificationConfiguration -> NotificationConfiguration -> Bool
$c== :: NotificationConfiguration -> NotificationConfiguration -> Bool
Prelude.Eq, ReadPrec [NotificationConfiguration]
ReadPrec NotificationConfiguration
Int -> ReadS NotificationConfiguration
ReadS [NotificationConfiguration]
(Int -> ReadS NotificationConfiguration)
-> ReadS [NotificationConfiguration]
-> ReadPrec NotificationConfiguration
-> ReadPrec [NotificationConfiguration]
-> Read NotificationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotificationConfiguration]
$creadListPrec :: ReadPrec [NotificationConfiguration]
readPrec :: ReadPrec NotificationConfiguration
$creadPrec :: ReadPrec NotificationConfiguration
readList :: ReadS [NotificationConfiguration]
$creadList :: ReadS [NotificationConfiguration]
readsPrec :: Int -> ReadS NotificationConfiguration
$creadsPrec :: Int -> ReadS NotificationConfiguration
Prelude.Read, Int -> NotificationConfiguration -> ShowS
[NotificationConfiguration] -> ShowS
NotificationConfiguration -> String
(Int -> NotificationConfiguration -> ShowS)
-> (NotificationConfiguration -> String)
-> ([NotificationConfiguration] -> ShowS)
-> Show NotificationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotificationConfiguration] -> ShowS
$cshowList :: [NotificationConfiguration] -> ShowS
show :: NotificationConfiguration -> String
$cshow :: NotificationConfiguration -> String
showsPrec :: Int -> NotificationConfiguration -> ShowS
$cshowsPrec :: Int -> NotificationConfiguration -> ShowS
Prelude.Show, (forall x.
 NotificationConfiguration -> Rep NotificationConfiguration x)
-> (forall x.
    Rep NotificationConfiguration x -> NotificationConfiguration)
-> Generic NotificationConfiguration
forall x.
Rep NotificationConfiguration x -> NotificationConfiguration
forall x.
NotificationConfiguration -> Rep NotificationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NotificationConfiguration x -> NotificationConfiguration
$cfrom :: forall x.
NotificationConfiguration -> Rep NotificationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'NotificationConfiguration' 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:
--
-- 'channels', 'notificationConfiguration_channels' - List of up to two channels to be used for sending notifications for
-- events detected from the application profile.
newNotificationConfiguration ::
  NotificationConfiguration
newNotificationConfiguration :: NotificationConfiguration
newNotificationConfiguration =
  NotificationConfiguration' :: Maybe (NonEmpty Channel) -> NotificationConfiguration
NotificationConfiguration'
    { $sel:channels:NotificationConfiguration' :: Maybe (NonEmpty Channel)
channels =
        Maybe (NonEmpty Channel)
forall a. Maybe a
Prelude.Nothing
    }

-- | List of up to two channels to be used for sending notifications for
-- events detected from the application profile.
notificationConfiguration_channels :: Lens.Lens' NotificationConfiguration (Prelude.Maybe (Prelude.NonEmpty Channel))
notificationConfiguration_channels :: (Maybe (NonEmpty Channel) -> f (Maybe (NonEmpty Channel)))
-> NotificationConfiguration -> f NotificationConfiguration
notificationConfiguration_channels = (NotificationConfiguration -> Maybe (NonEmpty Channel))
-> (NotificationConfiguration
    -> Maybe (NonEmpty Channel) -> NotificationConfiguration)
-> Lens
     NotificationConfiguration
     NotificationConfiguration
     (Maybe (NonEmpty Channel))
     (Maybe (NonEmpty Channel))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationConfiguration' {Maybe (NonEmpty Channel)
channels :: Maybe (NonEmpty Channel)
$sel:channels:NotificationConfiguration' :: NotificationConfiguration -> Maybe (NonEmpty Channel)
channels} -> Maybe (NonEmpty Channel)
channels) (\s :: NotificationConfiguration
s@NotificationConfiguration' {} Maybe (NonEmpty Channel)
a -> NotificationConfiguration
s {$sel:channels:NotificationConfiguration' :: Maybe (NonEmpty Channel)
channels = Maybe (NonEmpty Channel)
a} :: NotificationConfiguration) ((Maybe (NonEmpty Channel) -> f (Maybe (NonEmpty Channel)))
 -> NotificationConfiguration -> f NotificationConfiguration)
-> ((Maybe (NonEmpty Channel) -> f (Maybe (NonEmpty Channel)))
    -> Maybe (NonEmpty Channel) -> f (Maybe (NonEmpty Channel)))
-> (Maybe (NonEmpty Channel) -> f (Maybe (NonEmpty Channel)))
-> NotificationConfiguration
-> f NotificationConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Channel)
  (NonEmpty Channel)
  (NonEmpty Channel)
  (NonEmpty Channel)
-> Iso
     (Maybe (NonEmpty Channel))
     (Maybe (NonEmpty Channel))
     (Maybe (NonEmpty Channel))
     (Maybe (NonEmpty Channel))
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
  (NonEmpty Channel)
  (NonEmpty Channel)
  (NonEmpty Channel)
  (NonEmpty Channel)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON NotificationConfiguration where
  parseJSON :: Value -> Parser NotificationConfiguration
parseJSON =
    String
-> (Object -> Parser NotificationConfiguration)
-> Value
-> Parser NotificationConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NotificationConfiguration"
      ( \Object
x ->
          Maybe (NonEmpty Channel) -> NotificationConfiguration
NotificationConfiguration'
            (Maybe (NonEmpty Channel) -> NotificationConfiguration)
-> Parser (Maybe (NonEmpty Channel))
-> Parser NotificationConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Channel))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"channels")
      )

instance Prelude.Hashable NotificationConfiguration

instance Prelude.NFData NotificationConfiguration