{-# 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.CloudWatchLogs.Types.OutputLogEvent
-- 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.CloudWatchLogs.Types.OutputLogEvent where

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

-- | Represents a log event.
--
-- /See:/ 'newOutputLogEvent' smart constructor.
data OutputLogEvent = OutputLogEvent'
  { -- | The time the event was ingested, expressed as the number of milliseconds
    -- after Jan 1, 1970 00:00:00 UTC.
    OutputLogEvent -> Maybe Natural
ingestionTime :: Prelude.Maybe Prelude.Natural,
    -- | The data contained in the log event.
    OutputLogEvent -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The time the event occurred, expressed as the number of milliseconds
    -- after Jan 1, 1970 00:00:00 UTC.
    OutputLogEvent -> Maybe Natural
timestamp :: Prelude.Maybe Prelude.Natural
  }
  deriving (OutputLogEvent -> OutputLogEvent -> Bool
(OutputLogEvent -> OutputLogEvent -> Bool)
-> (OutputLogEvent -> OutputLogEvent -> Bool) -> Eq OutputLogEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputLogEvent -> OutputLogEvent -> Bool
$c/= :: OutputLogEvent -> OutputLogEvent -> Bool
== :: OutputLogEvent -> OutputLogEvent -> Bool
$c== :: OutputLogEvent -> OutputLogEvent -> Bool
Prelude.Eq, ReadPrec [OutputLogEvent]
ReadPrec OutputLogEvent
Int -> ReadS OutputLogEvent
ReadS [OutputLogEvent]
(Int -> ReadS OutputLogEvent)
-> ReadS [OutputLogEvent]
-> ReadPrec OutputLogEvent
-> ReadPrec [OutputLogEvent]
-> Read OutputLogEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputLogEvent]
$creadListPrec :: ReadPrec [OutputLogEvent]
readPrec :: ReadPrec OutputLogEvent
$creadPrec :: ReadPrec OutputLogEvent
readList :: ReadS [OutputLogEvent]
$creadList :: ReadS [OutputLogEvent]
readsPrec :: Int -> ReadS OutputLogEvent
$creadsPrec :: Int -> ReadS OutputLogEvent
Prelude.Read, Int -> OutputLogEvent -> ShowS
[OutputLogEvent] -> ShowS
OutputLogEvent -> String
(Int -> OutputLogEvent -> ShowS)
-> (OutputLogEvent -> String)
-> ([OutputLogEvent] -> ShowS)
-> Show OutputLogEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputLogEvent] -> ShowS
$cshowList :: [OutputLogEvent] -> ShowS
show :: OutputLogEvent -> String
$cshow :: OutputLogEvent -> String
showsPrec :: Int -> OutputLogEvent -> ShowS
$cshowsPrec :: Int -> OutputLogEvent -> ShowS
Prelude.Show, (forall x. OutputLogEvent -> Rep OutputLogEvent x)
-> (forall x. Rep OutputLogEvent x -> OutputLogEvent)
-> Generic OutputLogEvent
forall x. Rep OutputLogEvent x -> OutputLogEvent
forall x. OutputLogEvent -> Rep OutputLogEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputLogEvent x -> OutputLogEvent
$cfrom :: forall x. OutputLogEvent -> Rep OutputLogEvent x
Prelude.Generic)

-- |
-- Create a value of 'OutputLogEvent' 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:
--
-- 'ingestionTime', 'outputLogEvent_ingestionTime' - The time the event was ingested, expressed as the number of milliseconds
-- after Jan 1, 1970 00:00:00 UTC.
--
-- 'message', 'outputLogEvent_message' - The data contained in the log event.
--
-- 'timestamp', 'outputLogEvent_timestamp' - The time the event occurred, expressed as the number of milliseconds
-- after Jan 1, 1970 00:00:00 UTC.
newOutputLogEvent ::
  OutputLogEvent
newOutputLogEvent :: OutputLogEvent
newOutputLogEvent =
  OutputLogEvent' :: Maybe Natural -> Maybe Text -> Maybe Natural -> OutputLogEvent
OutputLogEvent'
    { $sel:ingestionTime:OutputLogEvent' :: Maybe Natural
ingestionTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:message:OutputLogEvent' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:OutputLogEvent' :: Maybe Natural
timestamp = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The time the event was ingested, expressed as the number of milliseconds
-- after Jan 1, 1970 00:00:00 UTC.
outputLogEvent_ingestionTime :: Lens.Lens' OutputLogEvent (Prelude.Maybe Prelude.Natural)
outputLogEvent_ingestionTime :: (Maybe Natural -> f (Maybe Natural))
-> OutputLogEvent -> f OutputLogEvent
outputLogEvent_ingestionTime = (OutputLogEvent -> Maybe Natural)
-> (OutputLogEvent -> Maybe Natural -> OutputLogEvent)
-> Lens
     OutputLogEvent OutputLogEvent (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputLogEvent' {Maybe Natural
ingestionTime :: Maybe Natural
$sel:ingestionTime:OutputLogEvent' :: OutputLogEvent -> Maybe Natural
ingestionTime} -> Maybe Natural
ingestionTime) (\s :: OutputLogEvent
s@OutputLogEvent' {} Maybe Natural
a -> OutputLogEvent
s {$sel:ingestionTime:OutputLogEvent' :: Maybe Natural
ingestionTime = Maybe Natural
a} :: OutputLogEvent)

-- | The data contained in the log event.
outputLogEvent_message :: Lens.Lens' OutputLogEvent (Prelude.Maybe Prelude.Text)
outputLogEvent_message :: (Maybe Text -> f (Maybe Text))
-> OutputLogEvent -> f OutputLogEvent
outputLogEvent_message = (OutputLogEvent -> Maybe Text)
-> (OutputLogEvent -> Maybe Text -> OutputLogEvent)
-> Lens OutputLogEvent OutputLogEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputLogEvent' {Maybe Text
message :: Maybe Text
$sel:message:OutputLogEvent' :: OutputLogEvent -> Maybe Text
message} -> Maybe Text
message) (\s :: OutputLogEvent
s@OutputLogEvent' {} Maybe Text
a -> OutputLogEvent
s {$sel:message:OutputLogEvent' :: Maybe Text
message = Maybe Text
a} :: OutputLogEvent)

-- | The time the event occurred, expressed as the number of milliseconds
-- after Jan 1, 1970 00:00:00 UTC.
outputLogEvent_timestamp :: Lens.Lens' OutputLogEvent (Prelude.Maybe Prelude.Natural)
outputLogEvent_timestamp :: (Maybe Natural -> f (Maybe Natural))
-> OutputLogEvent -> f OutputLogEvent
outputLogEvent_timestamp = (OutputLogEvent -> Maybe Natural)
-> (OutputLogEvent -> Maybe Natural -> OutputLogEvent)
-> Lens
     OutputLogEvent OutputLogEvent (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputLogEvent' {Maybe Natural
timestamp :: Maybe Natural
$sel:timestamp:OutputLogEvent' :: OutputLogEvent -> Maybe Natural
timestamp} -> Maybe Natural
timestamp) (\s :: OutputLogEvent
s@OutputLogEvent' {} Maybe Natural
a -> OutputLogEvent
s {$sel:timestamp:OutputLogEvent' :: Maybe Natural
timestamp = Maybe Natural
a} :: OutputLogEvent)

instance Core.FromJSON OutputLogEvent where
  parseJSON :: Value -> Parser OutputLogEvent
parseJSON =
    String
-> (Object -> Parser OutputLogEvent)
-> Value
-> Parser OutputLogEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OutputLogEvent"
      ( \Object
x ->
          Maybe Natural -> Maybe Text -> Maybe Natural -> OutputLogEvent
OutputLogEvent'
            (Maybe Natural -> Maybe Text -> Maybe Natural -> OutputLogEvent)
-> Parser (Maybe Natural)
-> Parser (Maybe Text -> Maybe Natural -> OutputLogEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ingestionTime")
            Parser (Maybe Text -> Maybe Natural -> OutputLogEvent)
-> Parser (Maybe Text) -> Parser (Maybe Natural -> OutputLogEvent)
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
"message")
            Parser (Maybe Natural -> OutputLogEvent)
-> Parser (Maybe Natural) -> Parser OutputLogEvent
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timestamp")
      )

instance Prelude.Hashable OutputLogEvent

instance Prelude.NFData OutputLogEvent