{-# 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.NotificationChannel
-- 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.NotificationChannel 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.NotificationChannelConfig
import qualified Amazonka.Prelude as Prelude

-- | Information about a notification channel. A notification channel is used
-- to notify you when DevOps Guru creates an insight. The one supported
-- notification channel is Amazon Simple Notification Service (Amazon SNS).
--
-- If you use an Amazon SNS topic in another account, you must attach a
-- policy to it that grants DevOps Guru permission to it notifications.
-- DevOps Guru adds the required policy on your behalf to send
-- notifications using Amazon SNS in your account. DevOps Guru only
-- supports standard SNS topics. For more information, see
-- <https://docs.aws.amazon.com/devops-guru/latest/userguide/sns-required-permissions.html Permissions for cross account Amazon SNS topics>.
--
-- If you use an Amazon SNS topic in another account, you must attach a
-- policy to it that grants DevOps Guru permission to it notifications.
-- DevOps Guru adds the required policy on your behalf to send
-- notifications using Amazon SNS in your account. For more information,
-- see Permissions for cross account Amazon SNS topics.
--
-- If you use an Amazon SNS topic that is encrypted by an Amazon Web
-- Services Key Management Service customer-managed key (CMK), then you
-- must add permissions to the CMK. For more information, see
-- <https://docs.aws.amazon.com/devops-guru/latest/userguide/sns-kms-permissions.html Permissions for Amazon Web Services KMS–encrypted Amazon SNS topics>.
--
-- /See:/ 'newNotificationChannel' smart constructor.
data NotificationChannel = NotificationChannel'
  { -- | A @NotificationChannelConfig@ object that contains information about
    -- configured notification channels.
    NotificationChannel -> Maybe NotificationChannelConfig
config :: Prelude.Maybe NotificationChannelConfig,
    -- | The ID of a notification channel.
    NotificationChannel -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (NotificationChannel -> NotificationChannel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotificationChannel -> NotificationChannel -> Bool
$c/= :: NotificationChannel -> NotificationChannel -> Bool
== :: NotificationChannel -> NotificationChannel -> Bool
$c== :: NotificationChannel -> NotificationChannel -> Bool
Prelude.Eq, ReadPrec [NotificationChannel]
ReadPrec NotificationChannel
Int -> ReadS NotificationChannel
ReadS [NotificationChannel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NotificationChannel]
$creadListPrec :: ReadPrec [NotificationChannel]
readPrec :: ReadPrec NotificationChannel
$creadPrec :: ReadPrec NotificationChannel
readList :: ReadS [NotificationChannel]
$creadList :: ReadS [NotificationChannel]
readsPrec :: Int -> ReadS NotificationChannel
$creadsPrec :: Int -> ReadS NotificationChannel
Prelude.Read, Int -> NotificationChannel -> ShowS
[NotificationChannel] -> ShowS
NotificationChannel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotificationChannel] -> ShowS
$cshowList :: [NotificationChannel] -> ShowS
show :: NotificationChannel -> String
$cshow :: NotificationChannel -> String
showsPrec :: Int -> NotificationChannel -> ShowS
$cshowsPrec :: Int -> NotificationChannel -> ShowS
Prelude.Show, forall x. Rep NotificationChannel x -> NotificationChannel
forall x. NotificationChannel -> Rep NotificationChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NotificationChannel x -> NotificationChannel
$cfrom :: forall x. NotificationChannel -> Rep NotificationChannel x
Prelude.Generic)

-- |
-- Create a value of 'NotificationChannel' 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:
--
-- 'config', 'notificationChannel_config' - A @NotificationChannelConfig@ object that contains information about
-- configured notification channels.
--
-- 'id', 'notificationChannel_id' - The ID of a notification channel.
newNotificationChannel ::
  NotificationChannel
newNotificationChannel :: NotificationChannel
newNotificationChannel =
  NotificationChannel'
    { $sel:config:NotificationChannel' :: Maybe NotificationChannelConfig
config = forall a. Maybe a
Prelude.Nothing,
      $sel:id:NotificationChannel' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing
    }

-- | A @NotificationChannelConfig@ object that contains information about
-- configured notification channels.
notificationChannel_config :: Lens.Lens' NotificationChannel (Prelude.Maybe NotificationChannelConfig)
notificationChannel_config :: Lens' NotificationChannel (Maybe NotificationChannelConfig)
notificationChannel_config = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationChannel' {Maybe NotificationChannelConfig
config :: Maybe NotificationChannelConfig
$sel:config:NotificationChannel' :: NotificationChannel -> Maybe NotificationChannelConfig
config} -> Maybe NotificationChannelConfig
config) (\s :: NotificationChannel
s@NotificationChannel' {} Maybe NotificationChannelConfig
a -> NotificationChannel
s {$sel:config:NotificationChannel' :: Maybe NotificationChannelConfig
config = Maybe NotificationChannelConfig
a} :: NotificationChannel)

-- | The ID of a notification channel.
notificationChannel_id :: Lens.Lens' NotificationChannel (Prelude.Maybe Prelude.Text)
notificationChannel_id :: Lens' NotificationChannel (Maybe Text)
notificationChannel_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationChannel' {Maybe Text
id :: Maybe Text
$sel:id:NotificationChannel' :: NotificationChannel -> Maybe Text
id} -> Maybe Text
id) (\s :: NotificationChannel
s@NotificationChannel' {} Maybe Text
a -> NotificationChannel
s {$sel:id:NotificationChannel' :: Maybe Text
id = Maybe Text
a} :: NotificationChannel)

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

instance Prelude.Hashable NotificationChannel where
  hashWithSalt :: Int -> NotificationChannel -> Int
hashWithSalt Int
_salt NotificationChannel' {Maybe Text
Maybe NotificationChannelConfig
id :: Maybe Text
config :: Maybe NotificationChannelConfig
$sel:id:NotificationChannel' :: NotificationChannel -> Maybe Text
$sel:config:NotificationChannel' :: NotificationChannel -> Maybe NotificationChannelConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NotificationChannelConfig
config
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id

instance Prelude.NFData NotificationChannel where
  rnf :: NotificationChannel -> ()
rnf NotificationChannel' {Maybe Text
Maybe NotificationChannelConfig
id :: Maybe Text
config :: Maybe NotificationChannelConfig
$sel:id:NotificationChannel' :: NotificationChannel -> Maybe Text
$sel:config:NotificationChannel' :: NotificationChannel -> Maybe NotificationChannelConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe NotificationChannelConfig
config seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id