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

import qualified Amazonka.Core as Core
import Amazonka.DevOpsGuru.Types.NotificationChannelConfig
import qualified Amazonka.Lens as Lens
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. 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 that is encrypted by an AWS 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 AWS 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
(NotificationChannel -> NotificationChannel -> Bool)
-> (NotificationChannel -> NotificationChannel -> Bool)
-> Eq NotificationChannel
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]
(Int -> ReadS NotificationChannel)
-> ReadS [NotificationChannel]
-> ReadPrec NotificationChannel
-> ReadPrec [NotificationChannel]
-> Read 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
(Int -> NotificationChannel -> ShowS)
-> (NotificationChannel -> String)
-> ([NotificationChannel] -> ShowS)
-> Show NotificationChannel
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. NotificationChannel -> Rep NotificationChannel x)
-> (forall x. Rep NotificationChannel x -> NotificationChannel)
-> Generic NotificationChannel
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' :: Maybe NotificationChannelConfig
-> Maybe Text -> NotificationChannel
NotificationChannel'
    { $sel:config:NotificationChannel' :: Maybe NotificationChannelConfig
config = Maybe NotificationChannelConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:id:NotificationChannel' :: Maybe Text
id = Maybe Text
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 :: (Maybe NotificationChannelConfig
 -> f (Maybe NotificationChannelConfig))
-> NotificationChannel -> f NotificationChannel
notificationChannel_config = (NotificationChannel -> Maybe NotificationChannelConfig)
-> (NotificationChannel
    -> Maybe NotificationChannelConfig -> NotificationChannel)
-> Lens
     NotificationChannel
     NotificationChannel
     (Maybe NotificationChannelConfig)
     (Maybe NotificationChannelConfig)
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 :: (Maybe Text -> f (Maybe Text))
-> NotificationChannel -> f NotificationChannel
notificationChannel_id = (NotificationChannel -> Maybe Text)
-> (NotificationChannel -> Maybe Text -> NotificationChannel)
-> Lens
     NotificationChannel NotificationChannel (Maybe Text) (Maybe Text)
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 Core.FromJSON NotificationChannel where
  parseJSON :: Value -> Parser NotificationChannel
parseJSON =
    String
-> (Object -> Parser NotificationChannel)
-> Value
-> Parser NotificationChannel
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NotificationChannel"
      ( \Object
x ->
          Maybe NotificationChannelConfig
-> Maybe Text -> NotificationChannel
NotificationChannel'
            (Maybe NotificationChannelConfig
 -> Maybe Text -> NotificationChannel)
-> Parser (Maybe NotificationChannelConfig)
-> Parser (Maybe Text -> NotificationChannel)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe NotificationChannelConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Config") Parser (Maybe Text -> NotificationChannel)
-> Parser (Maybe Text) -> Parser NotificationChannel
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
"Id")
      )

instance Prelude.Hashable NotificationChannel

instance Prelude.NFData NotificationChannel