{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DirectoryService.Types.EventTopic where

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

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

-- | 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 :: Lens' EventTopic (Maybe UTCTime)
eventTopic_createdDateTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | 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 :: Lens' EventTopic (Maybe Text)
eventTopic_directoryId = 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 topic registration status.
eventTopic_status :: Lens.Lens' EventTopic (Prelude.Maybe TopicStatus)
eventTopic_status :: Lens' EventTopic (Maybe TopicStatus)
eventTopic_status = 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 Amazon SNS topic ARN (Amazon Resource Name).
eventTopic_topicArn :: Lens.Lens' EventTopic (Prelude.Maybe Prelude.Text)
eventTopic_topicArn :: Lens' EventTopic (Maybe Text)
eventTopic_topicArn = 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 name of an Amazon SNS topic the receives status messages from the
-- directory.
eventTopic_topicName :: Lens.Lens' EventTopic (Prelude.Maybe Prelude.Text)
eventTopic_topicName :: Lens' EventTopic (Maybe Text)
eventTopic_topicName = 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)

instance Data.FromJSON EventTopic where
  parseJSON :: Value -> Parser EventTopic
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EventTopic"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text
-> Maybe TopicStatus
-> Maybe Text
-> Maybe Text
-> EventTopic
EventTopic'
            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
"CreatedDateTime")
            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
"DirectoryId")
            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
"Status")
            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
"TopicArn")
            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
"TopicName")
      )

instance Prelude.Hashable EventTopic where
  hashWithSalt :: Int -> EventTopic -> Int
hashWithSalt Int
_salt EventTopic' {Maybe Text
Maybe POSIX
Maybe TopicStatus
topicName :: Maybe Text
topicArn :: Maybe Text
status :: Maybe TopicStatus
directoryId :: Maybe Text
createdDateTime :: Maybe POSIX
$sel:topicName:EventTopic' :: EventTopic -> Maybe Text
$sel:topicArn:EventTopic' :: EventTopic -> Maybe Text
$sel:status:EventTopic' :: EventTopic -> Maybe TopicStatus
$sel:directoryId:EventTopic' :: EventTopic -> Maybe Text
$sel:createdDateTime:EventTopic' :: EventTopic -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdDateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
directoryId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TopicStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
topicArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
topicName

instance Prelude.NFData EventTopic where
  rnf :: EventTopic -> ()
rnf EventTopic' {Maybe Text
Maybe POSIX
Maybe TopicStatus
topicName :: Maybe Text
topicArn :: Maybe Text
status :: Maybe TopicStatus
directoryId :: Maybe Text
createdDateTime :: Maybe POSIX
$sel:topicName:EventTopic' :: EventTopic -> Maybe Text
$sel:topicArn:EventTopic' :: EventTopic -> Maybe Text
$sel:status:EventTopic' :: EventTopic -> Maybe TopicStatus
$sel:directoryId:EventTopic' :: EventTopic -> Maybe Text
$sel:createdDateTime:EventTopic' :: EventTopic -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdDateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
directoryId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TopicStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
topicArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
topicName