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

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

-- | Represents a log stream, which is a sequence of log events from a single
-- emitter of logs.
--
-- /See:/ 'newLogStream' smart constructor.
data LogStream = LogStream'
  { -- | The creation time of the stream, expressed as the number of milliseconds
    -- after Jan 1, 1970 00:00:00 UTC.
    LogStream -> Maybe Natural
creationTime :: Prelude.Maybe Prelude.Natural,
    -- | The sequence token.
    LogStream -> Maybe Text
uploadSequenceToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the log stream.
    LogStream -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The time of the first event, expressed as the number of milliseconds
    -- after Jan 1, 1970 00:00:00 UTC.
    LogStream -> Maybe Natural
firstEventTimestamp :: Prelude.Maybe Prelude.Natural,
    -- | The name of the log stream.
    LogStream -> Maybe Text
logStreamName :: Prelude.Maybe Prelude.Text,
    -- | The number of bytes stored.
    --
    -- __Important:__ On June 17, 2019, this parameter was deprecated for log
    -- streams, and is always reported as zero. This change applies only to log
    -- streams. The @storedBytes@ parameter for log groups is not affected.
    LogStream -> Maybe Natural
storedBytes :: Prelude.Maybe Prelude.Natural,
    -- | The ingestion time, expressed as the number of milliseconds after Jan 1,
    -- 1970 00:00:00 UTC.
    LogStream -> Maybe Natural
lastIngestionTime :: Prelude.Maybe Prelude.Natural,
    -- | The time of the most recent log event in the log stream in CloudWatch
    -- Logs. This number is expressed as the number of milliseconds after Jan
    -- 1, 1970 00:00:00 UTC. The @lastEventTime@ value updates on an eventual
    -- consistency basis. It typically updates in less than an hour from
    -- ingestion, but in rare situations might take longer.
    LogStream -> Maybe Natural
lastEventTimestamp :: Prelude.Maybe Prelude.Natural
  }
  deriving (LogStream -> LogStream -> Bool
(LogStream -> LogStream -> Bool)
-> (LogStream -> LogStream -> Bool) -> Eq LogStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogStream -> LogStream -> Bool
$c/= :: LogStream -> LogStream -> Bool
== :: LogStream -> LogStream -> Bool
$c== :: LogStream -> LogStream -> Bool
Prelude.Eq, ReadPrec [LogStream]
ReadPrec LogStream
Int -> ReadS LogStream
ReadS [LogStream]
(Int -> ReadS LogStream)
-> ReadS [LogStream]
-> ReadPrec LogStream
-> ReadPrec [LogStream]
-> Read LogStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogStream]
$creadListPrec :: ReadPrec [LogStream]
readPrec :: ReadPrec LogStream
$creadPrec :: ReadPrec LogStream
readList :: ReadS [LogStream]
$creadList :: ReadS [LogStream]
readsPrec :: Int -> ReadS LogStream
$creadsPrec :: Int -> ReadS LogStream
Prelude.Read, Int -> LogStream -> ShowS
[LogStream] -> ShowS
LogStream -> String
(Int -> LogStream -> ShowS)
-> (LogStream -> String)
-> ([LogStream] -> ShowS)
-> Show LogStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogStream] -> ShowS
$cshowList :: [LogStream] -> ShowS
show :: LogStream -> String
$cshow :: LogStream -> String
showsPrec :: Int -> LogStream -> ShowS
$cshowsPrec :: Int -> LogStream -> ShowS
Prelude.Show, (forall x. LogStream -> Rep LogStream x)
-> (forall x. Rep LogStream x -> LogStream) -> Generic LogStream
forall x. Rep LogStream x -> LogStream
forall x. LogStream -> Rep LogStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogStream x -> LogStream
$cfrom :: forall x. LogStream -> Rep LogStream x
Prelude.Generic)

-- |
-- Create a value of 'LogStream' 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:
--
-- 'creationTime', 'logStream_creationTime' - The creation time of the stream, expressed as the number of milliseconds
-- after Jan 1, 1970 00:00:00 UTC.
--
-- 'uploadSequenceToken', 'logStream_uploadSequenceToken' - The sequence token.
--
-- 'arn', 'logStream_arn' - The Amazon Resource Name (ARN) of the log stream.
--
-- 'firstEventTimestamp', 'logStream_firstEventTimestamp' - The time of the first event, expressed as the number of milliseconds
-- after Jan 1, 1970 00:00:00 UTC.
--
-- 'logStreamName', 'logStream_logStreamName' - The name of the log stream.
--
-- 'storedBytes', 'logStream_storedBytes' - The number of bytes stored.
--
-- __Important:__ On June 17, 2019, this parameter was deprecated for log
-- streams, and is always reported as zero. This change applies only to log
-- streams. The @storedBytes@ parameter for log groups is not affected.
--
-- 'lastIngestionTime', 'logStream_lastIngestionTime' - The ingestion time, expressed as the number of milliseconds after Jan 1,
-- 1970 00:00:00 UTC.
--
-- 'lastEventTimestamp', 'logStream_lastEventTimestamp' - The time of the most recent log event in the log stream in CloudWatch
-- Logs. This number is expressed as the number of milliseconds after Jan
-- 1, 1970 00:00:00 UTC. The @lastEventTime@ value updates on an eventual
-- consistency basis. It typically updates in less than an hour from
-- ingestion, but in rare situations might take longer.
newLogStream ::
  LogStream
newLogStream :: LogStream
newLogStream =
  LogStream' :: Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> LogStream
LogStream'
    { $sel:creationTime:LogStream' :: Maybe Natural
creationTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:uploadSequenceToken:LogStream' :: Maybe Text
uploadSequenceToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:LogStream' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:firstEventTimestamp:LogStream' :: Maybe Natural
firstEventTimestamp = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:logStreamName:LogStream' :: Maybe Text
logStreamName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:storedBytes:LogStream' :: Maybe Natural
storedBytes = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:lastIngestionTime:LogStream' :: Maybe Natural
lastIngestionTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:lastEventTimestamp:LogStream' :: Maybe Natural
lastEventTimestamp = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The sequence token.
logStream_uploadSequenceToken :: Lens.Lens' LogStream (Prelude.Maybe Prelude.Text)
logStream_uploadSequenceToken :: (Maybe Text -> f (Maybe Text)) -> LogStream -> f LogStream
logStream_uploadSequenceToken = (LogStream -> Maybe Text)
-> (LogStream -> Maybe Text -> LogStream)
-> Lens LogStream LogStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogStream' {Maybe Text
uploadSequenceToken :: Maybe Text
$sel:uploadSequenceToken:LogStream' :: LogStream -> Maybe Text
uploadSequenceToken} -> Maybe Text
uploadSequenceToken) (\s :: LogStream
s@LogStream' {} Maybe Text
a -> LogStream
s {$sel:uploadSequenceToken:LogStream' :: Maybe Text
uploadSequenceToken = Maybe Text
a} :: LogStream)

-- | The Amazon Resource Name (ARN) of the log stream.
logStream_arn :: Lens.Lens' LogStream (Prelude.Maybe Prelude.Text)
logStream_arn :: (Maybe Text -> f (Maybe Text)) -> LogStream -> f LogStream
logStream_arn = (LogStream -> Maybe Text)
-> (LogStream -> Maybe Text -> LogStream)
-> Lens LogStream LogStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogStream' {Maybe Text
arn :: Maybe Text
$sel:arn:LogStream' :: LogStream -> Maybe Text
arn} -> Maybe Text
arn) (\s :: LogStream
s@LogStream' {} Maybe Text
a -> LogStream
s {$sel:arn:LogStream' :: Maybe Text
arn = Maybe Text
a} :: LogStream)

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

-- | The name of the log stream.
logStream_logStreamName :: Lens.Lens' LogStream (Prelude.Maybe Prelude.Text)
logStream_logStreamName :: (Maybe Text -> f (Maybe Text)) -> LogStream -> f LogStream
logStream_logStreamName = (LogStream -> Maybe Text)
-> (LogStream -> Maybe Text -> LogStream)
-> Lens LogStream LogStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogStream' {Maybe Text
logStreamName :: Maybe Text
$sel:logStreamName:LogStream' :: LogStream -> Maybe Text
logStreamName} -> Maybe Text
logStreamName) (\s :: LogStream
s@LogStream' {} Maybe Text
a -> LogStream
s {$sel:logStreamName:LogStream' :: Maybe Text
logStreamName = Maybe Text
a} :: LogStream)

-- | The number of bytes stored.
--
-- __Important:__ On June 17, 2019, this parameter was deprecated for log
-- streams, and is always reported as zero. This change applies only to log
-- streams. The @storedBytes@ parameter for log groups is not affected.
logStream_storedBytes :: Lens.Lens' LogStream (Prelude.Maybe Prelude.Natural)
logStream_storedBytes :: (Maybe Natural -> f (Maybe Natural)) -> LogStream -> f LogStream
logStream_storedBytes = (LogStream -> Maybe Natural)
-> (LogStream -> Maybe Natural -> LogStream)
-> Lens LogStream LogStream (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogStream' {Maybe Natural
storedBytes :: Maybe Natural
$sel:storedBytes:LogStream' :: LogStream -> Maybe Natural
storedBytes} -> Maybe Natural
storedBytes) (\s :: LogStream
s@LogStream' {} Maybe Natural
a -> LogStream
s {$sel:storedBytes:LogStream' :: Maybe Natural
storedBytes = Maybe Natural
a} :: LogStream)

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

-- | The time of the most recent log event in the log stream in CloudWatch
-- Logs. This number is expressed as the number of milliseconds after Jan
-- 1, 1970 00:00:00 UTC. The @lastEventTime@ value updates on an eventual
-- consistency basis. It typically updates in less than an hour from
-- ingestion, but in rare situations might take longer.
logStream_lastEventTimestamp :: Lens.Lens' LogStream (Prelude.Maybe Prelude.Natural)
logStream_lastEventTimestamp :: (Maybe Natural -> f (Maybe Natural)) -> LogStream -> f LogStream
logStream_lastEventTimestamp = (LogStream -> Maybe Natural)
-> (LogStream -> Maybe Natural -> LogStream)
-> Lens LogStream LogStream (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogStream' {Maybe Natural
lastEventTimestamp :: Maybe Natural
$sel:lastEventTimestamp:LogStream' :: LogStream -> Maybe Natural
lastEventTimestamp} -> Maybe Natural
lastEventTimestamp) (\s :: LogStream
s@LogStream' {} Maybe Natural
a -> LogStream
s {$sel:lastEventTimestamp:LogStream' :: Maybe Natural
lastEventTimestamp = Maybe Natural
a} :: LogStream)

instance Core.FromJSON LogStream where
  parseJSON :: Value -> Parser LogStream
parseJSON =
    String -> (Object -> Parser LogStream) -> Value -> Parser LogStream
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LogStream"
      ( \Object
x ->
          Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> LogStream
LogStream'
            (Maybe Natural
 -> Maybe Text
 -> Maybe Text
 -> Maybe Natural
 -> Maybe Text
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> LogStream)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Natural
      -> Maybe Text
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> LogStream)
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
"creationTime")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Natural
   -> Maybe Text
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> LogStream)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Natural
      -> Maybe Text
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> LogStream)
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
"uploadSequenceToken")
            Parser
  (Maybe Text
   -> Maybe Natural
   -> Maybe Text
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> LogStream)
-> Parser (Maybe Text)
-> Parser
     (Maybe Natural
      -> Maybe Text
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> LogStream)
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
"arn")
            Parser
  (Maybe Natural
   -> Maybe Text
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> LogStream)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Text
      -> Maybe Natural -> Maybe Natural -> Maybe Natural -> LogStream)
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
"firstEventTimestamp")
            Parser
  (Maybe Text
   -> Maybe Natural -> Maybe Natural -> Maybe Natural -> LogStream)
-> Parser (Maybe Text)
-> Parser
     (Maybe Natural -> Maybe Natural -> Maybe Natural -> LogStream)
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
"logStreamName")
            Parser
  (Maybe Natural -> Maybe Natural -> Maybe Natural -> LogStream)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe Natural -> LogStream)
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
"storedBytes")
            Parser (Maybe Natural -> Maybe Natural -> LogStream)
-> Parser (Maybe Natural) -> Parser (Maybe Natural -> LogStream)
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
"lastIngestionTime")
            Parser (Maybe Natural -> LogStream)
-> Parser (Maybe Natural) -> Parser LogStream
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
"lastEventTimestamp")
      )

instance Prelude.Hashable LogStream

instance Prelude.NFData LogStream