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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Represents a log subscription, which tracks real-time data from a chosen
-- log group to a specified destination.
--
-- /See:/ 'newLogSubscription' smart constructor.
data LogSubscription = LogSubscription'
  { -- | Identifier (ID) of the directory that you want to associate with the log
    -- subscription.
    LogSubscription -> Maybe Text
directoryId :: Prelude.Maybe Prelude.Text,
    -- | The name of the log group.
    LogSubscription -> Maybe Text
logGroupName :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the log subscription was created.
    LogSubscription -> Maybe POSIX
subscriptionCreatedDateTime :: Prelude.Maybe Data.POSIX
  }
  deriving (LogSubscription -> LogSubscription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogSubscription -> LogSubscription -> Bool
$c/= :: LogSubscription -> LogSubscription -> Bool
== :: LogSubscription -> LogSubscription -> Bool
$c== :: LogSubscription -> LogSubscription -> Bool
Prelude.Eq, ReadPrec [LogSubscription]
ReadPrec LogSubscription
Int -> ReadS LogSubscription
ReadS [LogSubscription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogSubscription]
$creadListPrec :: ReadPrec [LogSubscription]
readPrec :: ReadPrec LogSubscription
$creadPrec :: ReadPrec LogSubscription
readList :: ReadS [LogSubscription]
$creadList :: ReadS [LogSubscription]
readsPrec :: Int -> ReadS LogSubscription
$creadsPrec :: Int -> ReadS LogSubscription
Prelude.Read, Int -> LogSubscription -> ShowS
[LogSubscription] -> ShowS
LogSubscription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogSubscription] -> ShowS
$cshowList :: [LogSubscription] -> ShowS
show :: LogSubscription -> String
$cshow :: LogSubscription -> String
showsPrec :: Int -> LogSubscription -> ShowS
$cshowsPrec :: Int -> LogSubscription -> ShowS
Prelude.Show, forall x. Rep LogSubscription x -> LogSubscription
forall x. LogSubscription -> Rep LogSubscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogSubscription x -> LogSubscription
$cfrom :: forall x. LogSubscription -> Rep LogSubscription x
Prelude.Generic)

-- |
-- Create a value of 'LogSubscription' 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:
--
-- 'directoryId', 'logSubscription_directoryId' - Identifier (ID) of the directory that you want to associate with the log
-- subscription.
--
-- 'logGroupName', 'logSubscription_logGroupName' - The name of the log group.
--
-- 'subscriptionCreatedDateTime', 'logSubscription_subscriptionCreatedDateTime' - The date and time that the log subscription was created.
newLogSubscription ::
  LogSubscription
newLogSubscription :: LogSubscription
newLogSubscription =
  LogSubscription'
    { $sel:directoryId:LogSubscription' :: Maybe Text
directoryId = forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupName:LogSubscription' :: Maybe Text
logGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:subscriptionCreatedDateTime:LogSubscription' :: Maybe POSIX
subscriptionCreatedDateTime = forall a. Maybe a
Prelude.Nothing
    }

-- | Identifier (ID) of the directory that you want to associate with the log
-- subscription.
logSubscription_directoryId :: Lens.Lens' LogSubscription (Prelude.Maybe Prelude.Text)
logSubscription_directoryId :: Lens' LogSubscription (Maybe Text)
logSubscription_directoryId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogSubscription' {Maybe Text
directoryId :: Maybe Text
$sel:directoryId:LogSubscription' :: LogSubscription -> Maybe Text
directoryId} -> Maybe Text
directoryId) (\s :: LogSubscription
s@LogSubscription' {} Maybe Text
a -> LogSubscription
s {$sel:directoryId:LogSubscription' :: Maybe Text
directoryId = Maybe Text
a} :: LogSubscription)

-- | The name of the log group.
logSubscription_logGroupName :: Lens.Lens' LogSubscription (Prelude.Maybe Prelude.Text)
logSubscription_logGroupName :: Lens' LogSubscription (Maybe Text)
logSubscription_logGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogSubscription' {Maybe Text
logGroupName :: Maybe Text
$sel:logGroupName:LogSubscription' :: LogSubscription -> Maybe Text
logGroupName} -> Maybe Text
logGroupName) (\s :: LogSubscription
s@LogSubscription' {} Maybe Text
a -> LogSubscription
s {$sel:logGroupName:LogSubscription' :: Maybe Text
logGroupName = Maybe Text
a} :: LogSubscription)

-- | The date and time that the log subscription was created.
logSubscription_subscriptionCreatedDateTime :: Lens.Lens' LogSubscription (Prelude.Maybe Prelude.UTCTime)
logSubscription_subscriptionCreatedDateTime :: Lens' LogSubscription (Maybe UTCTime)
logSubscription_subscriptionCreatedDateTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogSubscription' {Maybe POSIX
subscriptionCreatedDateTime :: Maybe POSIX
$sel:subscriptionCreatedDateTime:LogSubscription' :: LogSubscription -> Maybe POSIX
subscriptionCreatedDateTime} -> Maybe POSIX
subscriptionCreatedDateTime) (\s :: LogSubscription
s@LogSubscription' {} Maybe POSIX
a -> LogSubscription
s {$sel:subscriptionCreatedDateTime:LogSubscription' :: Maybe POSIX
subscriptionCreatedDateTime = Maybe POSIX
a} :: LogSubscription) 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

instance Data.FromJSON LogSubscription where
  parseJSON :: Value -> Parser LogSubscription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LogSubscription"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe POSIX -> LogSubscription
LogSubscription'
            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
"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
"LogGroupName")
            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
"SubscriptionCreatedDateTime")
      )

instance Prelude.Hashable LogSubscription where
  hashWithSalt :: Int -> LogSubscription -> Int
hashWithSalt Int
_salt LogSubscription' {Maybe Text
Maybe POSIX
subscriptionCreatedDateTime :: Maybe POSIX
logGroupName :: Maybe Text
directoryId :: Maybe Text
$sel:subscriptionCreatedDateTime:LogSubscription' :: LogSubscription -> Maybe POSIX
$sel:logGroupName:LogSubscription' :: LogSubscription -> Maybe Text
$sel:directoryId:LogSubscription' :: LogSubscription -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
directoryId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
logGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
subscriptionCreatedDateTime

instance Prelude.NFData LogSubscription where
  rnf :: LogSubscription -> ()
rnf LogSubscription' {Maybe Text
Maybe POSIX
subscriptionCreatedDateTime :: Maybe POSIX
logGroupName :: Maybe Text
directoryId :: Maybe Text
$sel:subscriptionCreatedDateTime:LogSubscription' :: LogSubscription -> Maybe POSIX
$sel:logGroupName:LogSubscription' :: LogSubscription -> Maybe Text
$sel:directoryId:LogSubscription' :: LogSubscription -> Maybe Text
..} =
    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 Text
logGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
subscriptionCreatedDateTime