{-# 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.DirectoryService.Types.EventTopic
-- 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.DirectoryService.Types.EventTopic where

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.Types.TopicStatus
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about Amazon SNS topic and Directory Service directory
-- associations.
--
-- /See:/ 'newEventTopic' smart constructor.
data EventTopic = EventTopic'
  { -- | The topic registration status.
    EventTopic -> Maybe TopicStatus
status :: Prelude.Maybe TopicStatus,
    -- | The Directory ID of an Directory Service directory that will publish
    -- status messages to an Amazon SNS topic.
    EventTopic -> Maybe Text
directoryId :: Prelude.Maybe Prelude.Text,
    -- | The name of an Amazon SNS topic the receives status messages from the
    -- directory.
    EventTopic -> Maybe Text
topicName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon SNS topic ARN (Amazon Resource Name).
    EventTopic -> Maybe Text
topicArn :: Prelude.Maybe Prelude.Text,
    -- | The date and time of when you associated your directory with the Amazon
    -- SNS topic.
    EventTopic -> Maybe POSIX
createdDateTime :: Prelude.Maybe Core.POSIX
  }
  deriving (EventTopic -> EventTopic -> Bool
(EventTopic -> EventTopic -> Bool)
-> (EventTopic -> EventTopic -> Bool) -> Eq EventTopic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventTopic -> EventTopic -> Bool
$c/= :: EventTopic -> EventTopic -> Bool
== :: EventTopic -> EventTopic -> Bool
$c== :: EventTopic -> EventTopic -> Bool
Prelude.Eq, ReadPrec [EventTopic]
ReadPrec EventTopic
Int -> ReadS EventTopic
ReadS [EventTopic]
(Int -> ReadS EventTopic)
-> ReadS [EventTopic]
-> ReadPrec EventTopic
-> ReadPrec [EventTopic]
-> Read EventTopic
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventTopic]
$creadListPrec :: ReadPrec [EventTopic]
readPrec :: ReadPrec EventTopic
$creadPrec :: ReadPrec EventTopic
readList :: ReadS [EventTopic]
$creadList :: ReadS [EventTopic]
readsPrec :: Int -> ReadS EventTopic
$creadsPrec :: Int -> ReadS EventTopic
Prelude.Read, Int -> EventTopic -> ShowS
[EventTopic] -> ShowS
EventTopic -> String
(Int -> EventTopic -> ShowS)
-> (EventTopic -> String)
-> ([EventTopic] -> ShowS)
-> Show EventTopic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventTopic] -> ShowS
$cshowList :: [EventTopic] -> ShowS
show :: EventTopic -> String
$cshow :: EventTopic -> String
showsPrec :: Int -> EventTopic -> ShowS
$cshowsPrec :: Int -> EventTopic -> ShowS
Prelude.Show, (forall x. EventTopic -> Rep EventTopic x)
-> (forall x. Rep EventTopic x -> EventTopic) -> Generic EventTopic
forall x. Rep EventTopic x -> EventTopic
forall x. EventTopic -> Rep EventTopic x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventTopic x -> EventTopic
$cfrom :: forall x. EventTopic -> Rep EventTopic x
Prelude.Generic)

-- |
-- Create a value of 'EventTopic' 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', 'eventTopic_status' - The topic registration status.
--
-- 'directoryId', 'eventTopic_directoryId' - The Directory ID of an Directory Service directory that will publish
-- status messages to an Amazon SNS topic.
--
-- 'topicName', 'eventTopic_topicName' - The name of an Amazon SNS topic the receives status messages from the
-- directory.
--
-- 'topicArn', 'eventTopic_topicArn' - The Amazon SNS topic ARN (Amazon Resource Name).
--
-- 'createdDateTime', 'eventTopic_createdDateTime' - The date and time of when you associated your directory with the Amazon
-- SNS topic.
newEventTopic ::
  EventTopic
newEventTopic :: EventTopic
newEventTopic =
  EventTopic' :: Maybe TopicStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> EventTopic
EventTopic'
    { $sel:status:EventTopic' :: Maybe TopicStatus
status = Maybe TopicStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:directoryId:EventTopic' :: Maybe Text
directoryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:topicName:EventTopic' :: Maybe Text
topicName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:topicArn:EventTopic' :: Maybe Text
topicArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdDateTime:EventTopic' :: Maybe POSIX
createdDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The topic registration status.
eventTopic_status :: Lens.Lens' EventTopic (Prelude.Maybe TopicStatus)
eventTopic_status :: (Maybe TopicStatus -> f (Maybe TopicStatus))
-> EventTopic -> f EventTopic
eventTopic_status = (EventTopic -> Maybe TopicStatus)
-> (EventTopic -> Maybe TopicStatus -> EventTopic)
-> Lens
     EventTopic EventTopic (Maybe TopicStatus) (Maybe TopicStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventTopic' {Maybe TopicStatus
status :: Maybe TopicStatus
$sel:status:EventTopic' :: EventTopic -> Maybe TopicStatus
status} -> Maybe TopicStatus
status) (\s :: EventTopic
s@EventTopic' {} Maybe TopicStatus
a -> EventTopic
s {$sel:status:EventTopic' :: Maybe TopicStatus
status = Maybe TopicStatus
a} :: EventTopic)

-- | The Directory ID of an Directory Service directory that will publish
-- status messages to an Amazon SNS topic.
eventTopic_directoryId :: Lens.Lens' EventTopic (Prelude.Maybe Prelude.Text)
eventTopic_directoryId :: (Maybe Text -> f (Maybe Text)) -> EventTopic -> f EventTopic
eventTopic_directoryId = (EventTopic -> Maybe Text)
-> (EventTopic -> Maybe Text -> EventTopic)
-> Lens EventTopic EventTopic (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventTopic' {Maybe Text
directoryId :: Maybe Text
$sel:directoryId:EventTopic' :: EventTopic -> Maybe Text
directoryId} -> Maybe Text
directoryId) (\s :: EventTopic
s@EventTopic' {} Maybe Text
a -> EventTopic
s {$sel:directoryId:EventTopic' :: Maybe Text
directoryId = Maybe Text
a} :: EventTopic)

-- | The name of an Amazon SNS topic the receives status messages from the
-- directory.
eventTopic_topicName :: Lens.Lens' EventTopic (Prelude.Maybe Prelude.Text)
eventTopic_topicName :: (Maybe Text -> f (Maybe Text)) -> EventTopic -> f EventTopic
eventTopic_topicName = (EventTopic -> Maybe Text)
-> (EventTopic -> Maybe Text -> EventTopic)
-> Lens EventTopic EventTopic (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventTopic' {Maybe Text
topicName :: Maybe Text
$sel:topicName:EventTopic' :: EventTopic -> Maybe Text
topicName} -> Maybe Text
topicName) (\s :: EventTopic
s@EventTopic' {} Maybe Text
a -> EventTopic
s {$sel:topicName:EventTopic' :: Maybe Text
topicName = Maybe Text
a} :: EventTopic)

-- | The Amazon SNS topic ARN (Amazon Resource Name).
eventTopic_topicArn :: Lens.Lens' EventTopic (Prelude.Maybe Prelude.Text)
eventTopic_topicArn :: (Maybe Text -> f (Maybe Text)) -> EventTopic -> f EventTopic
eventTopic_topicArn = (EventTopic -> Maybe Text)
-> (EventTopic -> Maybe Text -> EventTopic)
-> Lens EventTopic EventTopic (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventTopic' {Maybe Text
topicArn :: Maybe Text
$sel:topicArn:EventTopic' :: EventTopic -> Maybe Text
topicArn} -> Maybe Text
topicArn) (\s :: EventTopic
s@EventTopic' {} Maybe Text
a -> EventTopic
s {$sel:topicArn:EventTopic' :: Maybe Text
topicArn = Maybe Text
a} :: EventTopic)

-- | The date and time of when you associated your directory with the Amazon
-- SNS topic.
eventTopic_createdDateTime :: Lens.Lens' EventTopic (Prelude.Maybe Prelude.UTCTime)
eventTopic_createdDateTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> EventTopic -> f EventTopic
eventTopic_createdDateTime = (EventTopic -> Maybe POSIX)
-> (EventTopic -> Maybe POSIX -> EventTopic)
-> Lens EventTopic EventTopic (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventTopic' {Maybe POSIX
createdDateTime :: Maybe POSIX
$sel:createdDateTime:EventTopic' :: EventTopic -> Maybe POSIX
createdDateTime} -> Maybe POSIX
createdDateTime) (\s :: EventTopic
s@EventTopic' {} Maybe POSIX
a -> EventTopic
s {$sel:createdDateTime:EventTopic' :: Maybe POSIX
createdDateTime = Maybe POSIX
a} :: EventTopic) ((Maybe POSIX -> f (Maybe POSIX)) -> EventTopic -> f EventTopic)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EventTopic
-> f EventTopic
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON EventTopic where
  parseJSON :: Value -> Parser EventTopic
parseJSON =
    String
-> (Object -> Parser EventTopic) -> Value -> Parser EventTopic
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventTopic"
      ( \Object
x ->
          Maybe TopicStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> EventTopic
EventTopic'
            (Maybe TopicStatus
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> EventTopic)
-> Parser (Maybe TopicStatus)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe POSIX -> EventTopic)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TopicStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe POSIX -> EventTopic)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe POSIX -> EventTopic)
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
"DirectoryId")
            Parser (Maybe Text -> Maybe Text -> Maybe POSIX -> EventTopic)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> EventTopic)
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
"TopicName")
            Parser (Maybe Text -> Maybe POSIX -> EventTopic)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> EventTopic)
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
"TopicArn")
            Parser (Maybe POSIX -> EventTopic)
-> Parser (Maybe POSIX) -> Parser EventTopic
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreatedDateTime")
      )

instance Prelude.Hashable EventTopic

instance Prelude.NFData EventTopic