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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 Core.POSIX
  }
  deriving (LogSubscription -> LogSubscription -> Bool
(LogSubscription -> LogSubscription -> Bool)
-> (LogSubscription -> LogSubscription -> Bool)
-> Eq LogSubscription
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]
(Int -> ReadS LogSubscription)
-> ReadS [LogSubscription]
-> ReadPrec LogSubscription
-> ReadPrec [LogSubscription]
-> Read 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
(Int -> LogSubscription -> ShowS)
-> (LogSubscription -> String)
-> ([LogSubscription] -> ShowS)
-> Show LogSubscription
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. LogSubscription -> Rep LogSubscription x)
-> (forall x. Rep LogSubscription x -> LogSubscription)
-> Generic LogSubscription
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' :: Maybe Text -> Maybe Text -> Maybe POSIX -> LogSubscription
LogSubscription'
    { $sel:directoryId:LogSubscription' :: Maybe Text
directoryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupName:LogSubscription' :: Maybe Text
logGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subscriptionCreatedDateTime:LogSubscription' :: Maybe POSIX
subscriptionCreatedDateTime = Maybe POSIX
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 :: (Maybe Text -> f (Maybe Text))
-> LogSubscription -> f LogSubscription
logSubscription_directoryId = (LogSubscription -> Maybe Text)
-> (LogSubscription -> Maybe Text -> LogSubscription)
-> Lens LogSubscription LogSubscription (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> LogSubscription -> f LogSubscription
logSubscription_logGroupName = (LogSubscription -> Maybe Text)
-> (LogSubscription -> Maybe Text -> LogSubscription)
-> Lens LogSubscription LogSubscription (Maybe Text) (Maybe Text)
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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> LogSubscription -> f LogSubscription
logSubscription_subscriptionCreatedDateTime = (LogSubscription -> Maybe POSIX)
-> (LogSubscription -> Maybe POSIX -> LogSubscription)
-> Lens LogSubscription LogSubscription (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> LogSubscription -> f LogSubscription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> LogSubscription
-> f LogSubscription
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 LogSubscription where
  parseJSON :: Value -> Parser LogSubscription
parseJSON =
    String
-> (Object -> Parser LogSubscription)
-> Value
-> Parser LogSubscription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LogSubscription"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe POSIX -> LogSubscription
LogSubscription'
            (Maybe Text -> Maybe Text -> Maybe POSIX -> LogSubscription)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> LogSubscription)
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
"DirectoryId")
            Parser (Maybe Text -> Maybe POSIX -> LogSubscription)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> LogSubscription)
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
"LogGroupName")
            Parser (Maybe POSIX -> LogSubscription)
-> Parser (Maybe POSIX) -> Parser LogSubscription
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
"SubscriptionCreatedDateTime")
      )

instance Prelude.Hashable LogSubscription

instance Prelude.NFData LogSubscription