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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisVideo.Types.ConfigurationStatus
import Amazonka.KinesisVideo.Types.NotificationDestinationConfig
import qualified Amazonka.Prelude as Prelude

-- | The structure that contains the notification information for the KVS
-- images delivery. If this parameter is null, the configuration will be
-- deleted from the stream.
--
-- /See:/ 'newNotificationConfiguration' smart constructor.
data NotificationConfiguration = NotificationConfiguration'
  { -- | Indicates if a notification configuration is enabled or disabled.
    NotificationConfiguration -> ConfigurationStatus
status :: ConfigurationStatus,
    -- | The destination information required to deliver a notification to a
    -- customer.
    NotificationConfiguration -> NotificationDestinationConfig
destinationConfig :: NotificationDestinationConfig
  }
  deriving (NotificationConfiguration -> NotificationConfiguration -> Bool
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]
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
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.
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:
--
-- 'status', 'notificationConfiguration_status' - Indicates if a notification configuration is enabled or disabled.
--
-- 'destinationConfig', 'notificationConfiguration_destinationConfig' - The destination information required to deliver a notification to a
-- customer.
newNotificationConfiguration ::
  -- | 'status'
  ConfigurationStatus ->
  -- | 'destinationConfig'
  NotificationDestinationConfig ->
  NotificationConfiguration
newNotificationConfiguration :: ConfigurationStatus
-> NotificationDestinationConfig -> NotificationConfiguration
newNotificationConfiguration
  ConfigurationStatus
pStatus_
  NotificationDestinationConfig
pDestinationConfig_ =
    NotificationConfiguration'
      { $sel:status:NotificationConfiguration' :: ConfigurationStatus
status = ConfigurationStatus
pStatus_,
        $sel:destinationConfig:NotificationConfiguration' :: NotificationDestinationConfig
destinationConfig = NotificationDestinationConfig
pDestinationConfig_
      }

-- | Indicates if a notification configuration is enabled or disabled.
notificationConfiguration_status :: Lens.Lens' NotificationConfiguration ConfigurationStatus
notificationConfiguration_status :: Lens' NotificationConfiguration ConfigurationStatus
notificationConfiguration_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationConfiguration' {ConfigurationStatus
status :: ConfigurationStatus
$sel:status:NotificationConfiguration' :: NotificationConfiguration -> ConfigurationStatus
status} -> ConfigurationStatus
status) (\s :: NotificationConfiguration
s@NotificationConfiguration' {} ConfigurationStatus
a -> NotificationConfiguration
s {$sel:status:NotificationConfiguration' :: ConfigurationStatus
status = ConfigurationStatus
a} :: NotificationConfiguration)

-- | The destination information required to deliver a notification to a
-- customer.
notificationConfiguration_destinationConfig :: Lens.Lens' NotificationConfiguration NotificationDestinationConfig
notificationConfiguration_destinationConfig :: Lens' NotificationConfiguration NotificationDestinationConfig
notificationConfiguration_destinationConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NotificationConfiguration' {NotificationDestinationConfig
destinationConfig :: NotificationDestinationConfig
$sel:destinationConfig:NotificationConfiguration' :: NotificationConfiguration -> NotificationDestinationConfig
destinationConfig} -> NotificationDestinationConfig
destinationConfig) (\s :: NotificationConfiguration
s@NotificationConfiguration' {} NotificationDestinationConfig
a -> NotificationConfiguration
s {$sel:destinationConfig:NotificationConfiguration' :: NotificationDestinationConfig
destinationConfig = NotificationDestinationConfig
a} :: NotificationConfiguration)

instance Data.FromJSON NotificationConfiguration where
  parseJSON :: Value -> Parser NotificationConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NotificationConfiguration"
      ( \Object
x ->
          ConfigurationStatus
-> NotificationDestinationConfig -> NotificationConfiguration
NotificationConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DestinationConfig")
      )

instance Prelude.Hashable NotificationConfiguration where
  hashWithSalt :: Int -> NotificationConfiguration -> Int
hashWithSalt Int
_salt NotificationConfiguration' {ConfigurationStatus
NotificationDestinationConfig
destinationConfig :: NotificationDestinationConfig
status :: ConfigurationStatus
$sel:destinationConfig:NotificationConfiguration' :: NotificationConfiguration -> NotificationDestinationConfig
$sel:status:NotificationConfiguration' :: NotificationConfiguration -> ConfigurationStatus
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ConfigurationStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NotificationDestinationConfig
destinationConfig

instance Prelude.NFData NotificationConfiguration where
  rnf :: NotificationConfiguration -> ()
rnf NotificationConfiguration' {ConfigurationStatus
NotificationDestinationConfig
destinationConfig :: NotificationDestinationConfig
status :: ConfigurationStatus
$sel:destinationConfig:NotificationConfiguration' :: NotificationConfiguration -> NotificationDestinationConfig
$sel:status:NotificationConfiguration' :: NotificationConfiguration -> ConfigurationStatus
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ConfigurationStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NotificationDestinationConfig
destinationConfig

instance Data.ToJSON NotificationConfiguration where
  toJSON :: NotificationConfiguration -> Value
toJSON NotificationConfiguration' {ConfigurationStatus
NotificationDestinationConfig
destinationConfig :: NotificationDestinationConfig
status :: ConfigurationStatus
$sel:destinationConfig:NotificationConfiguration' :: NotificationConfiguration -> NotificationDestinationConfig
$sel:status:NotificationConfiguration' :: NotificationConfiguration -> ConfigurationStatus
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Status" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ConfigurationStatus
status),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"DestinationConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NotificationDestinationConfig
destinationConfig)
          ]
      )