{-# 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.InputLogEvent
-- 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.InputLogEvent 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, which is a record of activity that was recorded
-- by the application or resource being monitored.
--
-- /See:/ 'newInputLogEvent' smart constructor.
data InputLogEvent = InputLogEvent'
  { -- | The time the event occurred, expressed as the number of milliseconds
    -- after @Jan 1, 1970 00:00:00 UTC@.
    InputLogEvent -> Natural
timestamp :: Prelude.Natural,
    -- | The raw event message.
    InputLogEvent -> Text
message :: Prelude.Text
  }
  deriving (InputLogEvent -> InputLogEvent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputLogEvent -> InputLogEvent -> Bool
$c/= :: InputLogEvent -> InputLogEvent -> Bool
== :: InputLogEvent -> InputLogEvent -> Bool
$c== :: InputLogEvent -> InputLogEvent -> Bool
Prelude.Eq, ReadPrec [InputLogEvent]
ReadPrec InputLogEvent
Int -> ReadS InputLogEvent
ReadS [InputLogEvent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputLogEvent]
$creadListPrec :: ReadPrec [InputLogEvent]
readPrec :: ReadPrec InputLogEvent
$creadPrec :: ReadPrec InputLogEvent
readList :: ReadS [InputLogEvent]
$creadList :: ReadS [InputLogEvent]
readsPrec :: Int -> ReadS InputLogEvent
$creadsPrec :: Int -> ReadS InputLogEvent
Prelude.Read, Int -> InputLogEvent -> ShowS
[InputLogEvent] -> ShowS
InputLogEvent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputLogEvent] -> ShowS
$cshowList :: [InputLogEvent] -> ShowS
show :: InputLogEvent -> String
$cshow :: InputLogEvent -> String
showsPrec :: Int -> InputLogEvent -> ShowS
$cshowsPrec :: Int -> InputLogEvent -> ShowS
Prelude.Show, forall x. Rep InputLogEvent x -> InputLogEvent
forall x. InputLogEvent -> Rep InputLogEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputLogEvent x -> InputLogEvent
$cfrom :: forall x. InputLogEvent -> Rep InputLogEvent x
Prelude.Generic)

-- |
-- Create a value of 'InputLogEvent' 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:
--
-- 'timestamp', 'inputLogEvent_timestamp' - The time the event occurred, expressed as the number of milliseconds
-- after @Jan 1, 1970 00:00:00 UTC@.
--
-- 'message', 'inputLogEvent_message' - The raw event message.
newInputLogEvent ::
  -- | 'timestamp'
  Prelude.Natural ->
  -- | 'message'
  Prelude.Text ->
  InputLogEvent
newInputLogEvent :: Natural -> Text -> InputLogEvent
newInputLogEvent Natural
pTimestamp_ Text
pMessage_ =
  InputLogEvent'
    { $sel:timestamp:InputLogEvent' :: Natural
timestamp = Natural
pTimestamp_,
      $sel:message:InputLogEvent' :: Text
message = Text
pMessage_
    }

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

-- | The raw event message.
inputLogEvent_message :: Lens.Lens' InputLogEvent Prelude.Text
inputLogEvent_message :: Lens' InputLogEvent Text
inputLogEvent_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputLogEvent' {Text
message :: Text
$sel:message:InputLogEvent' :: InputLogEvent -> Text
message} -> Text
message) (\s :: InputLogEvent
s@InputLogEvent' {} Text
a -> InputLogEvent
s {$sel:message:InputLogEvent' :: Text
message = Text
a} :: InputLogEvent)

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

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

instance Data.ToJSON InputLogEvent where
  toJSON :: InputLogEvent -> Value
toJSON InputLogEvent' {Natural
Text
message :: Text
timestamp :: Natural
$sel:message:InputLogEvent' :: InputLogEvent -> Text
$sel:timestamp:InputLogEvent' :: InputLogEvent -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"timestamp" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
timestamp),
            forall a. a -> Maybe a
Prelude.Just (Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
message)
          ]
      )