{-# 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.Inspector.Types.AssessmentRunNotification
-- 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.Inspector.Types.AssessmentRunNotification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector.Types.AssessmentRunNotificationSnsStatusCode
import Amazonka.Inspector.Types.InspectorEvent
import qualified Amazonka.Prelude as Prelude

-- | Used as one of the elements of the AssessmentRun data type.
--
-- /See:/ 'newAssessmentRunNotification' smart constructor.
data AssessmentRunNotification = AssessmentRunNotification'
  { -- | The message included in the notification.
    AssessmentRunNotification -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The status code of the SNS notification.
    AssessmentRunNotification
-> Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode :: Prelude.Maybe AssessmentRunNotificationSnsStatusCode,
    -- | The SNS topic to which the SNS notification is sent.
    AssessmentRunNotification -> Maybe Text
snsTopicArn :: Prelude.Maybe Prelude.Text,
    -- | The date of the notification.
    AssessmentRunNotification -> POSIX
date :: Data.POSIX,
    -- | The event for which a notification is sent.
    AssessmentRunNotification -> InspectorEvent
event :: InspectorEvent,
    -- | The Boolean value that specifies whether the notification represents an
    -- error.
    AssessmentRunNotification -> Bool
error :: Prelude.Bool
  }
  deriving (AssessmentRunNotification -> AssessmentRunNotification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssessmentRunNotification -> AssessmentRunNotification -> Bool
$c/= :: AssessmentRunNotification -> AssessmentRunNotification -> Bool
== :: AssessmentRunNotification -> AssessmentRunNotification -> Bool
$c== :: AssessmentRunNotification -> AssessmentRunNotification -> Bool
Prelude.Eq, ReadPrec [AssessmentRunNotification]
ReadPrec AssessmentRunNotification
Int -> ReadS AssessmentRunNotification
ReadS [AssessmentRunNotification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssessmentRunNotification]
$creadListPrec :: ReadPrec [AssessmentRunNotification]
readPrec :: ReadPrec AssessmentRunNotification
$creadPrec :: ReadPrec AssessmentRunNotification
readList :: ReadS [AssessmentRunNotification]
$creadList :: ReadS [AssessmentRunNotification]
readsPrec :: Int -> ReadS AssessmentRunNotification
$creadsPrec :: Int -> ReadS AssessmentRunNotification
Prelude.Read, Int -> AssessmentRunNotification -> ShowS
[AssessmentRunNotification] -> ShowS
AssessmentRunNotification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssessmentRunNotification] -> ShowS
$cshowList :: [AssessmentRunNotification] -> ShowS
show :: AssessmentRunNotification -> String
$cshow :: AssessmentRunNotification -> String
showsPrec :: Int -> AssessmentRunNotification -> ShowS
$cshowsPrec :: Int -> AssessmentRunNotification -> ShowS
Prelude.Show, forall x.
Rep AssessmentRunNotification x -> AssessmentRunNotification
forall x.
AssessmentRunNotification -> Rep AssessmentRunNotification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssessmentRunNotification x -> AssessmentRunNotification
$cfrom :: forall x.
AssessmentRunNotification -> Rep AssessmentRunNotification x
Prelude.Generic)

-- |
-- Create a value of 'AssessmentRunNotification' 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:
--
-- 'message', 'assessmentRunNotification_message' - The message included in the notification.
--
-- 'snsPublishStatusCode', 'assessmentRunNotification_snsPublishStatusCode' - The status code of the SNS notification.
--
-- 'snsTopicArn', 'assessmentRunNotification_snsTopicArn' - The SNS topic to which the SNS notification is sent.
--
-- 'date', 'assessmentRunNotification_date' - The date of the notification.
--
-- 'event', 'assessmentRunNotification_event' - The event for which a notification is sent.
--
-- 'error', 'assessmentRunNotification_error' - The Boolean value that specifies whether the notification represents an
-- error.
newAssessmentRunNotification ::
  -- | 'date'
  Prelude.UTCTime ->
  -- | 'event'
  InspectorEvent ->
  -- | 'error'
  Prelude.Bool ->
  AssessmentRunNotification
newAssessmentRunNotification :: UTCTime -> InspectorEvent -> Bool -> AssessmentRunNotification
newAssessmentRunNotification UTCTime
pDate_ InspectorEvent
pEvent_ Bool
pError_ =
  AssessmentRunNotification'
    { $sel:message:AssessmentRunNotification' :: Maybe Text
message =
        forall a. Maybe a
Prelude.Nothing,
      $sel:snsPublishStatusCode:AssessmentRunNotification' :: Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode = forall a. Maybe a
Prelude.Nothing,
      $sel:snsTopicArn:AssessmentRunNotification' :: Maybe Text
snsTopicArn = forall a. Maybe a
Prelude.Nothing,
      $sel:date:AssessmentRunNotification' :: POSIX
date = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pDate_,
      $sel:event:AssessmentRunNotification' :: InspectorEvent
event = InspectorEvent
pEvent_,
      $sel:error:AssessmentRunNotification' :: Bool
error = Bool
pError_
    }

-- | The message included in the notification.
assessmentRunNotification_message :: Lens.Lens' AssessmentRunNotification (Prelude.Maybe Prelude.Text)
assessmentRunNotification_message :: Lens' AssessmentRunNotification (Maybe Text)
assessmentRunNotification_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentRunNotification' {Maybe Text
message :: Maybe Text
$sel:message:AssessmentRunNotification' :: AssessmentRunNotification -> Maybe Text
message} -> Maybe Text
message) (\s :: AssessmentRunNotification
s@AssessmentRunNotification' {} Maybe Text
a -> AssessmentRunNotification
s {$sel:message:AssessmentRunNotification' :: Maybe Text
message = Maybe Text
a} :: AssessmentRunNotification)

-- | The status code of the SNS notification.
assessmentRunNotification_snsPublishStatusCode :: Lens.Lens' AssessmentRunNotification (Prelude.Maybe AssessmentRunNotificationSnsStatusCode)
assessmentRunNotification_snsPublishStatusCode :: Lens'
  AssessmentRunNotification
  (Maybe AssessmentRunNotificationSnsStatusCode)
assessmentRunNotification_snsPublishStatusCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentRunNotification' {Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode :: Maybe AssessmentRunNotificationSnsStatusCode
$sel:snsPublishStatusCode:AssessmentRunNotification' :: AssessmentRunNotification
-> Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode} -> Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode) (\s :: AssessmentRunNotification
s@AssessmentRunNotification' {} Maybe AssessmentRunNotificationSnsStatusCode
a -> AssessmentRunNotification
s {$sel:snsPublishStatusCode:AssessmentRunNotification' :: Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode = Maybe AssessmentRunNotificationSnsStatusCode
a} :: AssessmentRunNotification)

-- | The SNS topic to which the SNS notification is sent.
assessmentRunNotification_snsTopicArn :: Lens.Lens' AssessmentRunNotification (Prelude.Maybe Prelude.Text)
assessmentRunNotification_snsTopicArn :: Lens' AssessmentRunNotification (Maybe Text)
assessmentRunNotification_snsTopicArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentRunNotification' {Maybe Text
snsTopicArn :: Maybe Text
$sel:snsTopicArn:AssessmentRunNotification' :: AssessmentRunNotification -> Maybe Text
snsTopicArn} -> Maybe Text
snsTopicArn) (\s :: AssessmentRunNotification
s@AssessmentRunNotification' {} Maybe Text
a -> AssessmentRunNotification
s {$sel:snsTopicArn:AssessmentRunNotification' :: Maybe Text
snsTopicArn = Maybe Text
a} :: AssessmentRunNotification)

-- | The date of the notification.
assessmentRunNotification_date :: Lens.Lens' AssessmentRunNotification Prelude.UTCTime
assessmentRunNotification_date :: Lens' AssessmentRunNotification UTCTime
assessmentRunNotification_date = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentRunNotification' {POSIX
date :: POSIX
$sel:date:AssessmentRunNotification' :: AssessmentRunNotification -> POSIX
date} -> POSIX
date) (\s :: AssessmentRunNotification
s@AssessmentRunNotification' {} POSIX
a -> AssessmentRunNotification
s {$sel:date:AssessmentRunNotification' :: POSIX
date = POSIX
a} :: AssessmentRunNotification) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The event for which a notification is sent.
assessmentRunNotification_event :: Lens.Lens' AssessmentRunNotification InspectorEvent
assessmentRunNotification_event :: Lens' AssessmentRunNotification InspectorEvent
assessmentRunNotification_event = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentRunNotification' {InspectorEvent
event :: InspectorEvent
$sel:event:AssessmentRunNotification' :: AssessmentRunNotification -> InspectorEvent
event} -> InspectorEvent
event) (\s :: AssessmentRunNotification
s@AssessmentRunNotification' {} InspectorEvent
a -> AssessmentRunNotification
s {$sel:event:AssessmentRunNotification' :: InspectorEvent
event = InspectorEvent
a} :: AssessmentRunNotification)

-- | The Boolean value that specifies whether the notification represents an
-- error.
assessmentRunNotification_error :: Lens.Lens' AssessmentRunNotification Prelude.Bool
assessmentRunNotification_error :: Lens' AssessmentRunNotification Bool
assessmentRunNotification_error = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentRunNotification' {Bool
error :: Bool
$sel:error:AssessmentRunNotification' :: AssessmentRunNotification -> Bool
error} -> Bool
error) (\s :: AssessmentRunNotification
s@AssessmentRunNotification' {} Bool
a -> AssessmentRunNotification
s {$sel:error:AssessmentRunNotification' :: Bool
error = Bool
a} :: AssessmentRunNotification)

instance Data.FromJSON AssessmentRunNotification where
  parseJSON :: Value -> Parser AssessmentRunNotification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AssessmentRunNotification"
      ( \Object
x ->
          Maybe Text
-> Maybe AssessmentRunNotificationSnsStatusCode
-> Maybe Text
-> POSIX
-> InspectorEvent
-> Bool
-> AssessmentRunNotification
AssessmentRunNotification'
            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
"message")
            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
"snsPublishStatusCode")
            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
"snsTopicArn")
            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
"date")
            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
"event")
            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
"error")
      )

instance Prelude.Hashable AssessmentRunNotification where
  hashWithSalt :: Int -> AssessmentRunNotification -> Int
hashWithSalt Int
_salt AssessmentRunNotification' {Bool
Maybe Text
Maybe AssessmentRunNotificationSnsStatusCode
POSIX
InspectorEvent
error :: Bool
event :: InspectorEvent
date :: POSIX
snsTopicArn :: Maybe Text
snsPublishStatusCode :: Maybe AssessmentRunNotificationSnsStatusCode
message :: Maybe Text
$sel:error:AssessmentRunNotification' :: AssessmentRunNotification -> Bool
$sel:event:AssessmentRunNotification' :: AssessmentRunNotification -> InspectorEvent
$sel:date:AssessmentRunNotification' :: AssessmentRunNotification -> POSIX
$sel:snsTopicArn:AssessmentRunNotification' :: AssessmentRunNotification -> Maybe Text
$sel:snsPublishStatusCode:AssessmentRunNotification' :: AssessmentRunNotification
-> Maybe AssessmentRunNotificationSnsStatusCode
$sel:message:AssessmentRunNotification' :: AssessmentRunNotification -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
snsTopicArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
date
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` InspectorEvent
event
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
error

instance Prelude.NFData AssessmentRunNotification where
  rnf :: AssessmentRunNotification -> ()
rnf AssessmentRunNotification' {Bool
Maybe Text
Maybe AssessmentRunNotificationSnsStatusCode
POSIX
InspectorEvent
error :: Bool
event :: InspectorEvent
date :: POSIX
snsTopicArn :: Maybe Text
snsPublishStatusCode :: Maybe AssessmentRunNotificationSnsStatusCode
message :: Maybe Text
$sel:error:AssessmentRunNotification' :: AssessmentRunNotification -> Bool
$sel:event:AssessmentRunNotification' :: AssessmentRunNotification -> InspectorEvent
$sel:date:AssessmentRunNotification' :: AssessmentRunNotification -> POSIX
$sel:snsTopicArn:AssessmentRunNotification' :: AssessmentRunNotification -> Maybe Text
$sel:snsPublishStatusCode:AssessmentRunNotification' :: AssessmentRunNotification
-> Maybe AssessmentRunNotificationSnsStatusCode
$sel:message:AssessmentRunNotification' :: AssessmentRunNotification -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
snsTopicArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
date
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf InspectorEvent
event
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
error