{-# 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.EventSubscription
-- 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.EventSubscription where

import qualified Amazonka.Core as Core
import Amazonka.Inspector.Types.InspectorEvent
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | This data type is used in the Subscription data type.
--
-- /See:/ 'newEventSubscription' smart constructor.
data EventSubscription = EventSubscription'
  { -- | The event for which Amazon Simple Notification Service (SNS)
    -- notifications are sent.
    EventSubscription -> InspectorEvent
event :: InspectorEvent,
    -- | The time at which SubscribeToEvent is called.
    EventSubscription -> POSIX
subscribedAt :: Core.POSIX
  }
  deriving (EventSubscription -> EventSubscription -> Bool
(EventSubscription -> EventSubscription -> Bool)
-> (EventSubscription -> EventSubscription -> Bool)
-> Eq EventSubscription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventSubscription -> EventSubscription -> Bool
$c/= :: EventSubscription -> EventSubscription -> Bool
== :: EventSubscription -> EventSubscription -> Bool
$c== :: EventSubscription -> EventSubscription -> Bool
Prelude.Eq, ReadPrec [EventSubscription]
ReadPrec EventSubscription
Int -> ReadS EventSubscription
ReadS [EventSubscription]
(Int -> ReadS EventSubscription)
-> ReadS [EventSubscription]
-> ReadPrec EventSubscription
-> ReadPrec [EventSubscription]
-> Read EventSubscription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventSubscription]
$creadListPrec :: ReadPrec [EventSubscription]
readPrec :: ReadPrec EventSubscription
$creadPrec :: ReadPrec EventSubscription
readList :: ReadS [EventSubscription]
$creadList :: ReadS [EventSubscription]
readsPrec :: Int -> ReadS EventSubscription
$creadsPrec :: Int -> ReadS EventSubscription
Prelude.Read, Int -> EventSubscription -> ShowS
[EventSubscription] -> ShowS
EventSubscription -> String
(Int -> EventSubscription -> ShowS)
-> (EventSubscription -> String)
-> ([EventSubscription] -> ShowS)
-> Show EventSubscription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventSubscription] -> ShowS
$cshowList :: [EventSubscription] -> ShowS
show :: EventSubscription -> String
$cshow :: EventSubscription -> String
showsPrec :: Int -> EventSubscription -> ShowS
$cshowsPrec :: Int -> EventSubscription -> ShowS
Prelude.Show, (forall x. EventSubscription -> Rep EventSubscription x)
-> (forall x. Rep EventSubscription x -> EventSubscription)
-> Generic EventSubscription
forall x. Rep EventSubscription x -> EventSubscription
forall x. EventSubscription -> Rep EventSubscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventSubscription x -> EventSubscription
$cfrom :: forall x. EventSubscription -> Rep EventSubscription x
Prelude.Generic)

-- |
-- Create a value of 'EventSubscription' 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:
--
-- 'event', 'eventSubscription_event' - The event for which Amazon Simple Notification Service (SNS)
-- notifications are sent.
--
-- 'subscribedAt', 'eventSubscription_subscribedAt' - The time at which SubscribeToEvent is called.
newEventSubscription ::
  -- | 'event'
  InspectorEvent ->
  -- | 'subscribedAt'
  Prelude.UTCTime ->
  EventSubscription
newEventSubscription :: InspectorEvent -> UTCTime -> EventSubscription
newEventSubscription InspectorEvent
pEvent_ UTCTime
pSubscribedAt_ =
  EventSubscription' :: InspectorEvent -> POSIX -> EventSubscription
EventSubscription'
    { $sel:event:EventSubscription' :: InspectorEvent
event = InspectorEvent
pEvent_,
      $sel:subscribedAt:EventSubscription' :: POSIX
subscribedAt = 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
pSubscribedAt_
    }

-- | The event for which Amazon Simple Notification Service (SNS)
-- notifications are sent.
eventSubscription_event :: Lens.Lens' EventSubscription InspectorEvent
eventSubscription_event :: (InspectorEvent -> f InspectorEvent)
-> EventSubscription -> f EventSubscription
eventSubscription_event = (EventSubscription -> InspectorEvent)
-> (EventSubscription -> InspectorEvent -> EventSubscription)
-> Lens
     EventSubscription EventSubscription InspectorEvent InspectorEvent
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSubscription' {InspectorEvent
event :: InspectorEvent
$sel:event:EventSubscription' :: EventSubscription -> InspectorEvent
event} -> InspectorEvent
event) (\s :: EventSubscription
s@EventSubscription' {} InspectorEvent
a -> EventSubscription
s {$sel:event:EventSubscription' :: InspectorEvent
event = InspectorEvent
a} :: EventSubscription)

-- | The time at which SubscribeToEvent is called.
eventSubscription_subscribedAt :: Lens.Lens' EventSubscription Prelude.UTCTime
eventSubscription_subscribedAt :: (UTCTime -> f UTCTime) -> EventSubscription -> f EventSubscription
eventSubscription_subscribedAt = (EventSubscription -> POSIX)
-> (EventSubscription -> POSIX -> EventSubscription)
-> Lens EventSubscription EventSubscription POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSubscription' {POSIX
subscribedAt :: POSIX
$sel:subscribedAt:EventSubscription' :: EventSubscription -> POSIX
subscribedAt} -> POSIX
subscribedAt) (\s :: EventSubscription
s@EventSubscription' {} POSIX
a -> EventSubscription
s {$sel:subscribedAt:EventSubscription' :: POSIX
subscribedAt = POSIX
a} :: EventSubscription) ((POSIX -> f POSIX) -> EventSubscription -> f EventSubscription)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> EventSubscription
-> f EventSubscription
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

instance Core.FromJSON EventSubscription where
  parseJSON :: Value -> Parser EventSubscription
parseJSON =
    String
-> (Object -> Parser EventSubscription)
-> Value
-> Parser EventSubscription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventSubscription"
      ( \Object
x ->
          InspectorEvent -> POSIX -> EventSubscription
EventSubscription'
            (InspectorEvent -> POSIX -> EventSubscription)
-> Parser InspectorEvent -> Parser (POSIX -> EventSubscription)
forall (f :: * -> *) a b. Functor 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 (POSIX -> EventSubscription)
-> Parser POSIX -> Parser EventSubscription
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
"subscribedAt")
      )

instance Prelude.Hashable EventSubscription

instance Prelude.NFData EventSubscription