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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(InputLogEvent -> InputLogEvent -> Bool)
-> (InputLogEvent -> InputLogEvent -> Bool) -> Eq InputLogEvent
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]
(Int -> ReadS InputLogEvent)
-> ReadS [InputLogEvent]
-> ReadPrec InputLogEvent
-> ReadPrec [InputLogEvent]
-> Read 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
(Int -> InputLogEvent -> ShowS)
-> (InputLogEvent -> String)
-> ([InputLogEvent] -> ShowS)
-> Show InputLogEvent
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. InputLogEvent -> Rep InputLogEvent x)
-> (forall x. Rep InputLogEvent x -> InputLogEvent)
-> Generic InputLogEvent
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' :: Natural -> Text -> InputLogEvent
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 :: (Natural -> f Natural) -> InputLogEvent -> f InputLogEvent
inputLogEvent_timestamp = (InputLogEvent -> Natural)
-> (InputLogEvent -> Natural -> InputLogEvent)
-> Lens InputLogEvent InputLogEvent Natural Natural
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 :: (Text -> f Text) -> InputLogEvent -> f InputLogEvent
inputLogEvent_message = (InputLogEvent -> Text)
-> (InputLogEvent -> Text -> InputLogEvent)
-> Lens InputLogEvent InputLogEvent Text Text
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

instance Prelude.NFData InputLogEvent

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"timestamp" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
timestamp),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"message" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
message)
          ]
      )