{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudWatchLogs.Types.OutputLogEvent 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 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
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]
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
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. 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'
    { $sel:ingestionTime:OutputLogEvent' :: Maybe Natural
ingestionTime = forall a. Maybe a
Prelude.Nothing,
      $sel:message:OutputLogEvent' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:OutputLogEvent' :: Maybe Natural
timestamp = 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 :: Lens' OutputLogEvent (Maybe Natural)
outputLogEvent_ingestionTime = 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 :: Lens' OutputLogEvent (Maybe Text)
outputLogEvent_message = 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 :: Lens' OutputLogEvent (Maybe Natural)
outputLogEvent_timestamp = 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 Data.FromJSON OutputLogEvent where
  parseJSON :: Value -> Parser OutputLogEvent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OutputLogEvent"
      ( \Object
x ->
          Maybe Natural -> Maybe Text -> Maybe Natural -> OutputLogEvent
OutputLogEvent'
            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
"ingestionTime")
            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
"message")
            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
"timestamp")
      )

instance Prelude.Hashable OutputLogEvent where
  hashWithSalt :: Int -> OutputLogEvent -> Int
hashWithSalt Int
_salt OutputLogEvent' {Maybe Natural
Maybe Text
timestamp :: Maybe Natural
message :: Maybe Text
ingestionTime :: Maybe Natural
$sel:timestamp:OutputLogEvent' :: OutputLogEvent -> Maybe Natural
$sel:message:OutputLogEvent' :: OutputLogEvent -> Maybe Text
$sel:ingestionTime:OutputLogEvent' :: OutputLogEvent -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
ingestionTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
timestamp

instance Prelude.NFData OutputLogEvent where
  rnf :: OutputLogEvent -> ()
rnf OutputLogEvent' {Maybe Natural
Maybe Text
timestamp :: Maybe Natural
message :: Maybe Text
ingestionTime :: Maybe Natural
$sel:timestamp:OutputLogEvent' :: OutputLogEvent -> Maybe Natural
$sel:message:OutputLogEvent' :: OutputLogEvent -> Maybe Text
$sel:ingestionTime:OutputLogEvent' :: OutputLogEvent -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
ingestionTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
timestamp