{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetLogEvents
-- 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)
--
-- Lists log events from the specified log stream. You can list all of the
-- log events or filter using a time range.
--
-- By default, this operation returns as many log events as can fit in a
-- response size of 1MB (up to 10,000 log events). You can get additional
-- log events by specifying one of the tokens in a subsequent call. This
-- operation can return empty results while there are more log events
-- available through the token.
module Amazonka.CloudWatchLogs.GetLogEvents
  ( -- * Creating a Request
    GetLogEvents (..),
    newGetLogEvents,

    -- * Request Lenses
    getLogEvents_startTime,
    getLogEvents_startFromHead,
    getLogEvents_nextToken,
    getLogEvents_endTime,
    getLogEvents_limit,
    getLogEvents_logGroupName,
    getLogEvents_logStreamName,

    -- * Destructuring the Response
    GetLogEventsResponse (..),
    newGetLogEventsResponse,

    -- * Response Lenses
    getLogEventsResponse_nextBackwardToken,
    getLogEventsResponse_nextForwardToken,
    getLogEventsResponse_events,
    getLogEventsResponse_httpStatus,
  )
where

import Amazonka.CloudWatchLogs.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetLogEvents' smart constructor.
data GetLogEvents = GetLogEvents'
  { -- | The start of the time range, expressed as the number of milliseconds
    -- after Jan 1, 1970 00:00:00 UTC. Events with a timestamp equal to this
    -- time or later than this time are included. Events with a timestamp
    -- earlier than this time are not included.
    GetLogEvents -> Maybe Natural
startTime :: Prelude.Maybe Prelude.Natural,
    -- | If the value is true, the earliest log events are returned first. If the
    -- value is false, the latest log events are returned first. The default
    -- value is false.
    --
    -- If you are using a previous @nextForwardToken@ value as the @nextToken@
    -- in this operation, you must specify @true@ for @startFromHead@.
    GetLogEvents -> Maybe Bool
startFromHead :: Prelude.Maybe Prelude.Bool,
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    GetLogEvents -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The end of the time range, expressed as the number of milliseconds after
    -- Jan 1, 1970 00:00:00 UTC. Events with a timestamp equal to or later than
    -- this time are not included.
    GetLogEvents -> Maybe Natural
endTime :: Prelude.Maybe Prelude.Natural,
    -- | The maximum number of log events returned. If you don\'t specify a
    -- value, the maximum is as many log events as can fit in a response size
    -- of 1 MB, up to 10,000 log events.
    GetLogEvents -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The name of the log group.
    GetLogEvents -> Text
logGroupName :: Prelude.Text,
    -- | The name of the log stream.
    GetLogEvents -> Text
logStreamName :: Prelude.Text
  }
  deriving (GetLogEvents -> GetLogEvents -> Bool
(GetLogEvents -> GetLogEvents -> Bool)
-> (GetLogEvents -> GetLogEvents -> Bool) -> Eq GetLogEvents
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLogEvents -> GetLogEvents -> Bool
$c/= :: GetLogEvents -> GetLogEvents -> Bool
== :: GetLogEvents -> GetLogEvents -> Bool
$c== :: GetLogEvents -> GetLogEvents -> Bool
Prelude.Eq, ReadPrec [GetLogEvents]
ReadPrec GetLogEvents
Int -> ReadS GetLogEvents
ReadS [GetLogEvents]
(Int -> ReadS GetLogEvents)
-> ReadS [GetLogEvents]
-> ReadPrec GetLogEvents
-> ReadPrec [GetLogEvents]
-> Read GetLogEvents
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLogEvents]
$creadListPrec :: ReadPrec [GetLogEvents]
readPrec :: ReadPrec GetLogEvents
$creadPrec :: ReadPrec GetLogEvents
readList :: ReadS [GetLogEvents]
$creadList :: ReadS [GetLogEvents]
readsPrec :: Int -> ReadS GetLogEvents
$creadsPrec :: Int -> ReadS GetLogEvents
Prelude.Read, Int -> GetLogEvents -> ShowS
[GetLogEvents] -> ShowS
GetLogEvents -> String
(Int -> GetLogEvents -> ShowS)
-> (GetLogEvents -> String)
-> ([GetLogEvents] -> ShowS)
-> Show GetLogEvents
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLogEvents] -> ShowS
$cshowList :: [GetLogEvents] -> ShowS
show :: GetLogEvents -> String
$cshow :: GetLogEvents -> String
showsPrec :: Int -> GetLogEvents -> ShowS
$cshowsPrec :: Int -> GetLogEvents -> ShowS
Prelude.Show, (forall x. GetLogEvents -> Rep GetLogEvents x)
-> (forall x. Rep GetLogEvents x -> GetLogEvents)
-> Generic GetLogEvents
forall x. Rep GetLogEvents x -> GetLogEvents
forall x. GetLogEvents -> Rep GetLogEvents x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLogEvents x -> GetLogEvents
$cfrom :: forall x. GetLogEvents -> Rep GetLogEvents x
Prelude.Generic)

-- |
-- Create a value of 'GetLogEvents' 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:
--
-- 'startTime', 'getLogEvents_startTime' - The start of the time range, expressed as the number of milliseconds
-- after Jan 1, 1970 00:00:00 UTC. Events with a timestamp equal to this
-- time or later than this time are included. Events with a timestamp
-- earlier than this time are not included.
--
-- 'startFromHead', 'getLogEvents_startFromHead' - If the value is true, the earliest log events are returned first. If the
-- value is false, the latest log events are returned first. The default
-- value is false.
--
-- If you are using a previous @nextForwardToken@ value as the @nextToken@
-- in this operation, you must specify @true@ for @startFromHead@.
--
-- 'nextToken', 'getLogEvents_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'endTime', 'getLogEvents_endTime' - The end of the time range, expressed as the number of milliseconds after
-- Jan 1, 1970 00:00:00 UTC. Events with a timestamp equal to or later than
-- this time are not included.
--
-- 'limit', 'getLogEvents_limit' - The maximum number of log events returned. If you don\'t specify a
-- value, the maximum is as many log events as can fit in a response size
-- of 1 MB, up to 10,000 log events.
--
-- 'logGroupName', 'getLogEvents_logGroupName' - The name of the log group.
--
-- 'logStreamName', 'getLogEvents_logStreamName' - The name of the log stream.
newGetLogEvents ::
  -- | 'logGroupName'
  Prelude.Text ->
  -- | 'logStreamName'
  Prelude.Text ->
  GetLogEvents
newGetLogEvents :: Text -> Text -> GetLogEvents
newGetLogEvents Text
pLogGroupName_ Text
pLogStreamName_ =
  GetLogEvents' :: Maybe Natural
-> Maybe Bool
-> Maybe Text
-> Maybe Natural
-> Maybe Natural
-> Text
-> Text
-> GetLogEvents
GetLogEvents'
    { $sel:startTime:GetLogEvents' :: Maybe Natural
startTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:startFromHead:GetLogEvents' :: Maybe Bool
startFromHead = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetLogEvents' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:GetLogEvents' :: Maybe Natural
endTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:GetLogEvents' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupName:GetLogEvents' :: Text
logGroupName = Text
pLogGroupName_,
      $sel:logStreamName:GetLogEvents' :: Text
logStreamName = Text
pLogStreamName_
    }

-- | The start of the time range, expressed as the number of milliseconds
-- after Jan 1, 1970 00:00:00 UTC. Events with a timestamp equal to this
-- time or later than this time are included. Events with a timestamp
-- earlier than this time are not included.
getLogEvents_startTime :: Lens.Lens' GetLogEvents (Prelude.Maybe Prelude.Natural)
getLogEvents_startTime :: (Maybe Natural -> f (Maybe Natural))
-> GetLogEvents -> f GetLogEvents
getLogEvents_startTime = (GetLogEvents -> Maybe Natural)
-> (GetLogEvents -> Maybe Natural -> GetLogEvents)
-> Lens GetLogEvents GetLogEvents (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEvents' {Maybe Natural
startTime :: Maybe Natural
$sel:startTime:GetLogEvents' :: GetLogEvents -> Maybe Natural
startTime} -> Maybe Natural
startTime) (\s :: GetLogEvents
s@GetLogEvents' {} Maybe Natural
a -> GetLogEvents
s {$sel:startTime:GetLogEvents' :: Maybe Natural
startTime = Maybe Natural
a} :: GetLogEvents)

-- | If the value is true, the earliest log events are returned first. If the
-- value is false, the latest log events are returned first. The default
-- value is false.
--
-- If you are using a previous @nextForwardToken@ value as the @nextToken@
-- in this operation, you must specify @true@ for @startFromHead@.
getLogEvents_startFromHead :: Lens.Lens' GetLogEvents (Prelude.Maybe Prelude.Bool)
getLogEvents_startFromHead :: (Maybe Bool -> f (Maybe Bool)) -> GetLogEvents -> f GetLogEvents
getLogEvents_startFromHead = (GetLogEvents -> Maybe Bool)
-> (GetLogEvents -> Maybe Bool -> GetLogEvents)
-> Lens GetLogEvents GetLogEvents (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEvents' {Maybe Bool
startFromHead :: Maybe Bool
$sel:startFromHead:GetLogEvents' :: GetLogEvents -> Maybe Bool
startFromHead} -> Maybe Bool
startFromHead) (\s :: GetLogEvents
s@GetLogEvents' {} Maybe Bool
a -> GetLogEvents
s {$sel:startFromHead:GetLogEvents' :: Maybe Bool
startFromHead = Maybe Bool
a} :: GetLogEvents)

-- | The token for the next set of items to return. (You received this token
-- from a previous call.)
getLogEvents_nextToken :: Lens.Lens' GetLogEvents (Prelude.Maybe Prelude.Text)
getLogEvents_nextToken :: (Maybe Text -> f (Maybe Text)) -> GetLogEvents -> f GetLogEvents
getLogEvents_nextToken = (GetLogEvents -> Maybe Text)
-> (GetLogEvents -> Maybe Text -> GetLogEvents)
-> Lens GetLogEvents GetLogEvents (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEvents' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetLogEvents' :: GetLogEvents -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetLogEvents
s@GetLogEvents' {} Maybe Text
a -> GetLogEvents
s {$sel:nextToken:GetLogEvents' :: Maybe Text
nextToken = Maybe Text
a} :: GetLogEvents)

-- | The end of the time range, expressed as the number of milliseconds after
-- Jan 1, 1970 00:00:00 UTC. Events with a timestamp equal to or later than
-- this time are not included.
getLogEvents_endTime :: Lens.Lens' GetLogEvents (Prelude.Maybe Prelude.Natural)
getLogEvents_endTime :: (Maybe Natural -> f (Maybe Natural))
-> GetLogEvents -> f GetLogEvents
getLogEvents_endTime = (GetLogEvents -> Maybe Natural)
-> (GetLogEvents -> Maybe Natural -> GetLogEvents)
-> Lens GetLogEvents GetLogEvents (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEvents' {Maybe Natural
endTime :: Maybe Natural
$sel:endTime:GetLogEvents' :: GetLogEvents -> Maybe Natural
endTime} -> Maybe Natural
endTime) (\s :: GetLogEvents
s@GetLogEvents' {} Maybe Natural
a -> GetLogEvents
s {$sel:endTime:GetLogEvents' :: Maybe Natural
endTime = Maybe Natural
a} :: GetLogEvents)

-- | The maximum number of log events returned. If you don\'t specify a
-- value, the maximum is as many log events as can fit in a response size
-- of 1 MB, up to 10,000 log events.
getLogEvents_limit :: Lens.Lens' GetLogEvents (Prelude.Maybe Prelude.Natural)
getLogEvents_limit :: (Maybe Natural -> f (Maybe Natural))
-> GetLogEvents -> f GetLogEvents
getLogEvents_limit = (GetLogEvents -> Maybe Natural)
-> (GetLogEvents -> Maybe Natural -> GetLogEvents)
-> Lens GetLogEvents GetLogEvents (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEvents' {Maybe Natural
limit :: Maybe Natural
$sel:limit:GetLogEvents' :: GetLogEvents -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: GetLogEvents
s@GetLogEvents' {} Maybe Natural
a -> GetLogEvents
s {$sel:limit:GetLogEvents' :: Maybe Natural
limit = Maybe Natural
a} :: GetLogEvents)

-- | The name of the log group.
getLogEvents_logGroupName :: Lens.Lens' GetLogEvents Prelude.Text
getLogEvents_logGroupName :: (Text -> f Text) -> GetLogEvents -> f GetLogEvents
getLogEvents_logGroupName = (GetLogEvents -> Text)
-> (GetLogEvents -> Text -> GetLogEvents)
-> Lens GetLogEvents GetLogEvents Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEvents' {Text
logGroupName :: Text
$sel:logGroupName:GetLogEvents' :: GetLogEvents -> Text
logGroupName} -> Text
logGroupName) (\s :: GetLogEvents
s@GetLogEvents' {} Text
a -> GetLogEvents
s {$sel:logGroupName:GetLogEvents' :: Text
logGroupName = Text
a} :: GetLogEvents)

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

instance Core.AWSRequest GetLogEvents where
  type AWSResponse GetLogEvents = GetLogEventsResponse
  request :: GetLogEvents -> Request GetLogEvents
request = Service -> GetLogEvents -> Request GetLogEvents
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetLogEvents
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetLogEvents)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetLogEvents))
-> Logger
-> Service
-> Proxy GetLogEvents
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetLogEvents)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe [OutputLogEvent]
-> Int
-> GetLogEventsResponse
GetLogEventsResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe [OutputLogEvent]
 -> Int
 -> GetLogEventsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe [OutputLogEvent] -> Int -> GetLogEventsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextBackwardToken")
            Either
  String
  (Maybe Text
   -> Maybe [OutputLogEvent] -> Int -> GetLogEventsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [OutputLogEvent] -> Int -> GetLogEventsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextForwardToken")
            Either
  String (Maybe [OutputLogEvent] -> Int -> GetLogEventsResponse)
-> Either String (Maybe [OutputLogEvent])
-> Either String (Int -> GetLogEventsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [OutputLogEvent]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"events" Either String (Maybe (Maybe [OutputLogEvent]))
-> Maybe [OutputLogEvent] -> Either String (Maybe [OutputLogEvent])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [OutputLogEvent]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetLogEventsResponse)
-> Either String Int -> Either String GetLogEventsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetLogEvents

instance Prelude.NFData GetLogEvents

instance Core.ToHeaders GetLogEvents where
  toHeaders :: GetLogEvents -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetLogEvents -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"Logs_20140328.GetLogEvents" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetLogEvents where
  toJSON :: GetLogEvents -> Value
toJSON GetLogEvents' {Maybe Bool
Maybe Natural
Maybe Text
Text
logStreamName :: Text
logGroupName :: Text
limit :: Maybe Natural
endTime :: Maybe Natural
nextToken :: Maybe Text
startFromHead :: Maybe Bool
startTime :: Maybe Natural
$sel:logStreamName:GetLogEvents' :: GetLogEvents -> Text
$sel:logGroupName:GetLogEvents' :: GetLogEvents -> Text
$sel:limit:GetLogEvents' :: GetLogEvents -> Maybe Natural
$sel:endTime:GetLogEvents' :: GetLogEvents -> Maybe Natural
$sel:nextToken:GetLogEvents' :: GetLogEvents -> Maybe Text
$sel:startFromHead:GetLogEvents' :: GetLogEvents -> Maybe Bool
$sel:startTime:GetLogEvents' :: GetLogEvents -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"startTime" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
startTime,
            (Text
"startFromHead" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
startFromHead,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"endTime" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
endTime,
            (Text
"limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"logGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logGroupName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"logStreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logStreamName)
          ]
      )

instance Core.ToPath GetLogEvents where
  toPath :: GetLogEvents -> ByteString
toPath = ByteString -> GetLogEvents -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery GetLogEvents where
  toQuery :: GetLogEvents -> QueryString
toQuery = QueryString -> GetLogEvents -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetLogEventsResponse' smart constructor.
data GetLogEventsResponse = GetLogEventsResponse'
  { -- | The token for the next set of items in the backward direction. The token
    -- expires after 24 hours. This token is never null. If you have reached
    -- the end of the stream, it returns the same token you passed in.
    GetLogEventsResponse -> Maybe Text
nextBackwardToken :: Prelude.Maybe Prelude.Text,
    -- | The token for the next set of items in the forward direction. The token
    -- expires after 24 hours. If you have reached the end of the stream, it
    -- returns the same token you passed in.
    GetLogEventsResponse -> Maybe Text
nextForwardToken :: Prelude.Maybe Prelude.Text,
    -- | The events.
    GetLogEventsResponse -> Maybe [OutputLogEvent]
events :: Prelude.Maybe [OutputLogEvent],
    -- | The response's http status code.
    GetLogEventsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetLogEventsResponse -> GetLogEventsResponse -> Bool
(GetLogEventsResponse -> GetLogEventsResponse -> Bool)
-> (GetLogEventsResponse -> GetLogEventsResponse -> Bool)
-> Eq GetLogEventsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLogEventsResponse -> GetLogEventsResponse -> Bool
$c/= :: GetLogEventsResponse -> GetLogEventsResponse -> Bool
== :: GetLogEventsResponse -> GetLogEventsResponse -> Bool
$c== :: GetLogEventsResponse -> GetLogEventsResponse -> Bool
Prelude.Eq, ReadPrec [GetLogEventsResponse]
ReadPrec GetLogEventsResponse
Int -> ReadS GetLogEventsResponse
ReadS [GetLogEventsResponse]
(Int -> ReadS GetLogEventsResponse)
-> ReadS [GetLogEventsResponse]
-> ReadPrec GetLogEventsResponse
-> ReadPrec [GetLogEventsResponse]
-> Read GetLogEventsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLogEventsResponse]
$creadListPrec :: ReadPrec [GetLogEventsResponse]
readPrec :: ReadPrec GetLogEventsResponse
$creadPrec :: ReadPrec GetLogEventsResponse
readList :: ReadS [GetLogEventsResponse]
$creadList :: ReadS [GetLogEventsResponse]
readsPrec :: Int -> ReadS GetLogEventsResponse
$creadsPrec :: Int -> ReadS GetLogEventsResponse
Prelude.Read, Int -> GetLogEventsResponse -> ShowS
[GetLogEventsResponse] -> ShowS
GetLogEventsResponse -> String
(Int -> GetLogEventsResponse -> ShowS)
-> (GetLogEventsResponse -> String)
-> ([GetLogEventsResponse] -> ShowS)
-> Show GetLogEventsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLogEventsResponse] -> ShowS
$cshowList :: [GetLogEventsResponse] -> ShowS
show :: GetLogEventsResponse -> String
$cshow :: GetLogEventsResponse -> String
showsPrec :: Int -> GetLogEventsResponse -> ShowS
$cshowsPrec :: Int -> GetLogEventsResponse -> ShowS
Prelude.Show, (forall x. GetLogEventsResponse -> Rep GetLogEventsResponse x)
-> (forall x. Rep GetLogEventsResponse x -> GetLogEventsResponse)
-> Generic GetLogEventsResponse
forall x. Rep GetLogEventsResponse x -> GetLogEventsResponse
forall x. GetLogEventsResponse -> Rep GetLogEventsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLogEventsResponse x -> GetLogEventsResponse
$cfrom :: forall x. GetLogEventsResponse -> Rep GetLogEventsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetLogEventsResponse' 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:
--
-- 'nextBackwardToken', 'getLogEventsResponse_nextBackwardToken' - The token for the next set of items in the backward direction. The token
-- expires after 24 hours. This token is never null. If you have reached
-- the end of the stream, it returns the same token you passed in.
--
-- 'nextForwardToken', 'getLogEventsResponse_nextForwardToken' - The token for the next set of items in the forward direction. The token
-- expires after 24 hours. If you have reached the end of the stream, it
-- returns the same token you passed in.
--
-- 'events', 'getLogEventsResponse_events' - The events.
--
-- 'httpStatus', 'getLogEventsResponse_httpStatus' - The response's http status code.
newGetLogEventsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetLogEventsResponse
newGetLogEventsResponse :: Int -> GetLogEventsResponse
newGetLogEventsResponse Int
pHttpStatus_ =
  GetLogEventsResponse' :: Maybe Text
-> Maybe Text
-> Maybe [OutputLogEvent]
-> Int
-> GetLogEventsResponse
GetLogEventsResponse'
    { $sel:nextBackwardToken:GetLogEventsResponse' :: Maybe Text
nextBackwardToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextForwardToken:GetLogEventsResponse' :: Maybe Text
nextForwardToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:events:GetLogEventsResponse' :: Maybe [OutputLogEvent]
events = Maybe [OutputLogEvent]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetLogEventsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token for the next set of items in the backward direction. The token
-- expires after 24 hours. This token is never null. If you have reached
-- the end of the stream, it returns the same token you passed in.
getLogEventsResponse_nextBackwardToken :: Lens.Lens' GetLogEventsResponse (Prelude.Maybe Prelude.Text)
getLogEventsResponse_nextBackwardToken :: (Maybe Text -> f (Maybe Text))
-> GetLogEventsResponse -> f GetLogEventsResponse
getLogEventsResponse_nextBackwardToken = (GetLogEventsResponse -> Maybe Text)
-> (GetLogEventsResponse -> Maybe Text -> GetLogEventsResponse)
-> Lens
     GetLogEventsResponse GetLogEventsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEventsResponse' {Maybe Text
nextBackwardToken :: Maybe Text
$sel:nextBackwardToken:GetLogEventsResponse' :: GetLogEventsResponse -> Maybe Text
nextBackwardToken} -> Maybe Text
nextBackwardToken) (\s :: GetLogEventsResponse
s@GetLogEventsResponse' {} Maybe Text
a -> GetLogEventsResponse
s {$sel:nextBackwardToken:GetLogEventsResponse' :: Maybe Text
nextBackwardToken = Maybe Text
a} :: GetLogEventsResponse)

-- | The token for the next set of items in the forward direction. The token
-- expires after 24 hours. If you have reached the end of the stream, it
-- returns the same token you passed in.
getLogEventsResponse_nextForwardToken :: Lens.Lens' GetLogEventsResponse (Prelude.Maybe Prelude.Text)
getLogEventsResponse_nextForwardToken :: (Maybe Text -> f (Maybe Text))
-> GetLogEventsResponse -> f GetLogEventsResponse
getLogEventsResponse_nextForwardToken = (GetLogEventsResponse -> Maybe Text)
-> (GetLogEventsResponse -> Maybe Text -> GetLogEventsResponse)
-> Lens
     GetLogEventsResponse GetLogEventsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEventsResponse' {Maybe Text
nextForwardToken :: Maybe Text
$sel:nextForwardToken:GetLogEventsResponse' :: GetLogEventsResponse -> Maybe Text
nextForwardToken} -> Maybe Text
nextForwardToken) (\s :: GetLogEventsResponse
s@GetLogEventsResponse' {} Maybe Text
a -> GetLogEventsResponse
s {$sel:nextForwardToken:GetLogEventsResponse' :: Maybe Text
nextForwardToken = Maybe Text
a} :: GetLogEventsResponse)

-- | The events.
getLogEventsResponse_events :: Lens.Lens' GetLogEventsResponse (Prelude.Maybe [OutputLogEvent])
getLogEventsResponse_events :: (Maybe [OutputLogEvent] -> f (Maybe [OutputLogEvent]))
-> GetLogEventsResponse -> f GetLogEventsResponse
getLogEventsResponse_events = (GetLogEventsResponse -> Maybe [OutputLogEvent])
-> (GetLogEventsResponse
    -> Maybe [OutputLogEvent] -> GetLogEventsResponse)
-> Lens
     GetLogEventsResponse
     GetLogEventsResponse
     (Maybe [OutputLogEvent])
     (Maybe [OutputLogEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEventsResponse' {Maybe [OutputLogEvent]
events :: Maybe [OutputLogEvent]
$sel:events:GetLogEventsResponse' :: GetLogEventsResponse -> Maybe [OutputLogEvent]
events} -> Maybe [OutputLogEvent]
events) (\s :: GetLogEventsResponse
s@GetLogEventsResponse' {} Maybe [OutputLogEvent]
a -> GetLogEventsResponse
s {$sel:events:GetLogEventsResponse' :: Maybe [OutputLogEvent]
events = Maybe [OutputLogEvent]
a} :: GetLogEventsResponse) ((Maybe [OutputLogEvent] -> f (Maybe [OutputLogEvent]))
 -> GetLogEventsResponse -> f GetLogEventsResponse)
-> ((Maybe [OutputLogEvent] -> f (Maybe [OutputLogEvent]))
    -> Maybe [OutputLogEvent] -> f (Maybe [OutputLogEvent]))
-> (Maybe [OutputLogEvent] -> f (Maybe [OutputLogEvent]))
-> GetLogEventsResponse
-> f GetLogEventsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [OutputLogEvent] [OutputLogEvent] [OutputLogEvent] [OutputLogEvent]
-> Iso
     (Maybe [OutputLogEvent])
     (Maybe [OutputLogEvent])
     (Maybe [OutputLogEvent])
     (Maybe [OutputLogEvent])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [OutputLogEvent] [OutputLogEvent] [OutputLogEvent] [OutputLogEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
getLogEventsResponse_httpStatus :: Lens.Lens' GetLogEventsResponse Prelude.Int
getLogEventsResponse_httpStatus :: (Int -> f Int) -> GetLogEventsResponse -> f GetLogEventsResponse
getLogEventsResponse_httpStatus = (GetLogEventsResponse -> Int)
-> (GetLogEventsResponse -> Int -> GetLogEventsResponse)
-> Lens GetLogEventsResponse GetLogEventsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLogEventsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetLogEventsResponse' :: GetLogEventsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetLogEventsResponse
s@GetLogEventsResponse' {} Int
a -> GetLogEventsResponse
s {$sel:httpStatus:GetLogEventsResponse' :: Int
httpStatus = Int
a} :: GetLogEventsResponse)

instance Prelude.NFData GetLogEventsResponse