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

import qualified Amazonka.Core as Core
import Amazonka.Inspector.Types.AssessmentRunNotificationSnsStatusCode
import Amazonka.Inspector.Types.InspectorEvent
import qualified Amazonka.Lens as Lens
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 SNS topic to which the SNS notification is sent.
    AssessmentRunNotification -> Maybe Text
snsTopicArn :: Prelude.Maybe Prelude.Text,
    -- | The status code of the SNS notification.
    AssessmentRunNotification
-> Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode :: Prelude.Maybe AssessmentRunNotificationSnsStatusCode,
    -- | The message included in the notification.
    AssessmentRunNotification -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The date of the notification.
    AssessmentRunNotification -> POSIX
date :: Core.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
(AssessmentRunNotification -> AssessmentRunNotification -> Bool)
-> (AssessmentRunNotification -> AssessmentRunNotification -> Bool)
-> Eq AssessmentRunNotification
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]
(Int -> ReadS AssessmentRunNotification)
-> ReadS [AssessmentRunNotification]
-> ReadPrec AssessmentRunNotification
-> ReadPrec [AssessmentRunNotification]
-> Read 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
(Int -> AssessmentRunNotification -> ShowS)
-> (AssessmentRunNotification -> String)
-> ([AssessmentRunNotification] -> ShowS)
-> Show AssessmentRunNotification
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.
 AssessmentRunNotification -> Rep AssessmentRunNotification x)
-> (forall x.
    Rep AssessmentRunNotification x -> AssessmentRunNotification)
-> Generic AssessmentRunNotification
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:
--
-- 'snsTopicArn', 'assessmentRunNotification_snsTopicArn' - The SNS topic to which the SNS notification is sent.
--
-- 'snsPublishStatusCode', 'assessmentRunNotification_snsPublishStatusCode' - The status code of the SNS notification.
--
-- 'message', 'assessmentRunNotification_message' - The message included in the notification.
--
-- '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' :: Maybe Text
-> Maybe AssessmentRunNotificationSnsStatusCode
-> Maybe Text
-> POSIX
-> InspectorEvent
-> Bool
-> AssessmentRunNotification
AssessmentRunNotification'
    { $sel:snsTopicArn:AssessmentRunNotification' :: Maybe Text
snsTopicArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:snsPublishStatusCode:AssessmentRunNotification' :: Maybe AssessmentRunNotificationSnsStatusCode
snsPublishStatusCode = Maybe AssessmentRunNotificationSnsStatusCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:AssessmentRunNotification' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:date:AssessmentRunNotification' :: POSIX
date = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
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 SNS topic to which the SNS notification is sent.
assessmentRunNotification_snsTopicArn :: Lens.Lens' AssessmentRunNotification (Prelude.Maybe Prelude.Text)
assessmentRunNotification_snsTopicArn :: (Maybe Text -> f (Maybe Text))
-> AssessmentRunNotification -> f AssessmentRunNotification
assessmentRunNotification_snsTopicArn = (AssessmentRunNotification -> Maybe Text)
-> (AssessmentRunNotification
    -> Maybe Text -> AssessmentRunNotification)
-> Lens
     AssessmentRunNotification
     AssessmentRunNotification
     (Maybe Text)
     (Maybe Text)
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 status code of the SNS notification.
assessmentRunNotification_snsPublishStatusCode :: Lens.Lens' AssessmentRunNotification (Prelude.Maybe AssessmentRunNotificationSnsStatusCode)
assessmentRunNotification_snsPublishStatusCode :: (Maybe AssessmentRunNotificationSnsStatusCode
 -> f (Maybe AssessmentRunNotificationSnsStatusCode))
-> AssessmentRunNotification -> f AssessmentRunNotification
assessmentRunNotification_snsPublishStatusCode = (AssessmentRunNotification
 -> Maybe AssessmentRunNotificationSnsStatusCode)
-> (AssessmentRunNotification
    -> Maybe AssessmentRunNotificationSnsStatusCode
    -> AssessmentRunNotification)
-> Lens
     AssessmentRunNotification
     AssessmentRunNotification
     (Maybe AssessmentRunNotificationSnsStatusCode)
     (Maybe AssessmentRunNotificationSnsStatusCode)
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 message included in the notification.
assessmentRunNotification_message :: Lens.Lens' AssessmentRunNotification (Prelude.Maybe Prelude.Text)
assessmentRunNotification_message :: (Maybe Text -> f (Maybe Text))
-> AssessmentRunNotification -> f AssessmentRunNotification
assessmentRunNotification_message = (AssessmentRunNotification -> Maybe Text)
-> (AssessmentRunNotification
    -> Maybe Text -> AssessmentRunNotification)
-> Lens
     AssessmentRunNotification
     AssessmentRunNotification
     (Maybe Text)
     (Maybe Text)
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 date of the notification.
assessmentRunNotification_date :: Lens.Lens' AssessmentRunNotification Prelude.UTCTime
assessmentRunNotification_date :: (UTCTime -> f UTCTime)
-> AssessmentRunNotification -> f AssessmentRunNotification
assessmentRunNotification_date = (AssessmentRunNotification -> POSIX)
-> (AssessmentRunNotification
    -> POSIX -> AssessmentRunNotification)
-> Lens
     AssessmentRunNotification AssessmentRunNotification POSIX POSIX
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) ((POSIX -> f POSIX)
 -> AssessmentRunNotification -> f AssessmentRunNotification)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> AssessmentRunNotification
-> f AssessmentRunNotification
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The event for which a notification is sent.
assessmentRunNotification_event :: Lens.Lens' AssessmentRunNotification InspectorEvent
assessmentRunNotification_event :: (InspectorEvent -> f InspectorEvent)
-> AssessmentRunNotification -> f AssessmentRunNotification
assessmentRunNotification_event = (AssessmentRunNotification -> InspectorEvent)
-> (AssessmentRunNotification
    -> InspectorEvent -> AssessmentRunNotification)
-> Lens
     AssessmentRunNotification
     AssessmentRunNotification
     InspectorEvent
     InspectorEvent
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 :: (Bool -> f Bool)
-> AssessmentRunNotification -> f AssessmentRunNotification
assessmentRunNotification_error = (AssessmentRunNotification -> Bool)
-> (AssessmentRunNotification -> Bool -> AssessmentRunNotification)
-> Lens
     AssessmentRunNotification AssessmentRunNotification Bool Bool
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 Core.FromJSON AssessmentRunNotification where
  parseJSON :: Value -> Parser AssessmentRunNotification
parseJSON =
    String
-> (Object -> Parser AssessmentRunNotification)
-> Value
-> Parser AssessmentRunNotification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssessmentRunNotification"
      ( \Object
x ->
          Maybe Text
-> Maybe AssessmentRunNotificationSnsStatusCode
-> Maybe Text
-> POSIX
-> InspectorEvent
-> Bool
-> AssessmentRunNotification
AssessmentRunNotification'
            (Maybe Text
 -> Maybe AssessmentRunNotificationSnsStatusCode
 -> Maybe Text
 -> POSIX
 -> InspectorEvent
 -> Bool
 -> AssessmentRunNotification)
-> Parser (Maybe Text)
-> Parser
     (Maybe AssessmentRunNotificationSnsStatusCode
      -> Maybe Text
      -> POSIX
      -> InspectorEvent
      -> Bool
      -> AssessmentRunNotification)
forall (f :: * -> *) a b. Functor 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
"snsTopicArn")
            Parser
  (Maybe AssessmentRunNotificationSnsStatusCode
   -> Maybe Text
   -> POSIX
   -> InspectorEvent
   -> Bool
   -> AssessmentRunNotification)
-> Parser (Maybe AssessmentRunNotificationSnsStatusCode)
-> Parser
     (Maybe Text
      -> POSIX -> InspectorEvent -> Bool -> AssessmentRunNotification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe AssessmentRunNotificationSnsStatusCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"snsPublishStatusCode")
            Parser
  (Maybe Text
   -> POSIX -> InspectorEvent -> Bool -> AssessmentRunNotification)
-> Parser (Maybe Text)
-> Parser
     (POSIX -> InspectorEvent -> Bool -> AssessmentRunNotification)
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
"message")
            Parser
  (POSIX -> InspectorEvent -> Bool -> AssessmentRunNotification)
-> Parser POSIX
-> Parser (InspectorEvent -> Bool -> AssessmentRunNotification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"date")
            Parser (InspectorEvent -> Bool -> AssessmentRunNotification)
-> Parser InspectorEvent
-> Parser (Bool -> AssessmentRunNotification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser InspectorEvent
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"event")
            Parser (Bool -> AssessmentRunNotification)
-> Parser Bool -> Parser AssessmentRunNotification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"error")
      )

instance Prelude.Hashable AssessmentRunNotification

instance Prelude.NFData AssessmentRunNotification