{-# 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.DescribeLogStreams
-- 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 the log streams for the specified log group. You can list all the
-- log streams or filter the results by prefix. You can also control how
-- the results are ordered.
--
-- This operation has a limit of five transactions per second, after which
-- transactions are throttled.
--
-- This operation returns paginated results.
module Amazonka.CloudWatchLogs.DescribeLogStreams
  ( -- * Creating a Request
    DescribeLogStreams (..),
    newDescribeLogStreams,

    -- * Request Lenses
    describeLogStreams_orderBy,
    describeLogStreams_descending,
    describeLogStreams_nextToken,
    describeLogStreams_logStreamNamePrefix,
    describeLogStreams_limit,
    describeLogStreams_logGroupName,

    -- * Destructuring the Response
    DescribeLogStreamsResponse (..),
    newDescribeLogStreamsResponse,

    -- * Response Lenses
    describeLogStreamsResponse_nextToken,
    describeLogStreamsResponse_logStreams,
    describeLogStreamsResponse_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:/ 'newDescribeLogStreams' smart constructor.
data DescribeLogStreams = DescribeLogStreams'
  { -- | If the value is @LogStreamName@, the results are ordered by log stream
    -- name. If the value is @LastEventTime@, the results are ordered by the
    -- event time. The default value is @LogStreamName@.
    --
    -- If you order the results by event time, you cannot specify the
    -- @logStreamNamePrefix@ parameter.
    --
    -- @lastEventTimestamp@ represents 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.
    -- @lastEventTimestamp@ updates on an eventual consistency basis. It
    -- typically updates in less than an hour from ingestion, but in rare
    -- situations might take longer.
    DescribeLogStreams -> Maybe OrderBy
orderBy :: Prelude.Maybe OrderBy,
    -- | If the value is true, results are returned in descending order. If the
    -- value is to false, results are returned in ascending order. The default
    -- value is false.
    DescribeLogStreams -> Maybe Bool
descending :: Prelude.Maybe Prelude.Bool,
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    DescribeLogStreams -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The prefix to match.
    --
    -- If @orderBy@ is @LastEventTime@, you cannot specify this parameter.
    DescribeLogStreams -> Maybe Text
logStreamNamePrefix :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items returned. If you don\'t specify a value, the
    -- default is up to 50 items.
    DescribeLogStreams -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The name of the log group.
    DescribeLogStreams -> Text
logGroupName :: Prelude.Text
  }
  deriving (DescribeLogStreams -> DescribeLogStreams -> Bool
(DescribeLogStreams -> DescribeLogStreams -> Bool)
-> (DescribeLogStreams -> DescribeLogStreams -> Bool)
-> Eq DescribeLogStreams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLogStreams -> DescribeLogStreams -> Bool
$c/= :: DescribeLogStreams -> DescribeLogStreams -> Bool
== :: DescribeLogStreams -> DescribeLogStreams -> Bool
$c== :: DescribeLogStreams -> DescribeLogStreams -> Bool
Prelude.Eq, ReadPrec [DescribeLogStreams]
ReadPrec DescribeLogStreams
Int -> ReadS DescribeLogStreams
ReadS [DescribeLogStreams]
(Int -> ReadS DescribeLogStreams)
-> ReadS [DescribeLogStreams]
-> ReadPrec DescribeLogStreams
-> ReadPrec [DescribeLogStreams]
-> Read DescribeLogStreams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLogStreams]
$creadListPrec :: ReadPrec [DescribeLogStreams]
readPrec :: ReadPrec DescribeLogStreams
$creadPrec :: ReadPrec DescribeLogStreams
readList :: ReadS [DescribeLogStreams]
$creadList :: ReadS [DescribeLogStreams]
readsPrec :: Int -> ReadS DescribeLogStreams
$creadsPrec :: Int -> ReadS DescribeLogStreams
Prelude.Read, Int -> DescribeLogStreams -> ShowS
[DescribeLogStreams] -> ShowS
DescribeLogStreams -> String
(Int -> DescribeLogStreams -> ShowS)
-> (DescribeLogStreams -> String)
-> ([DescribeLogStreams] -> ShowS)
-> Show DescribeLogStreams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLogStreams] -> ShowS
$cshowList :: [DescribeLogStreams] -> ShowS
show :: DescribeLogStreams -> String
$cshow :: DescribeLogStreams -> String
showsPrec :: Int -> DescribeLogStreams -> ShowS
$cshowsPrec :: Int -> DescribeLogStreams -> ShowS
Prelude.Show, (forall x. DescribeLogStreams -> Rep DescribeLogStreams x)
-> (forall x. Rep DescribeLogStreams x -> DescribeLogStreams)
-> Generic DescribeLogStreams
forall x. Rep DescribeLogStreams x -> DescribeLogStreams
forall x. DescribeLogStreams -> Rep DescribeLogStreams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeLogStreams x -> DescribeLogStreams
$cfrom :: forall x. DescribeLogStreams -> Rep DescribeLogStreams x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLogStreams' 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:
--
-- 'orderBy', 'describeLogStreams_orderBy' - If the value is @LogStreamName@, the results are ordered by log stream
-- name. If the value is @LastEventTime@, the results are ordered by the
-- event time. The default value is @LogStreamName@.
--
-- If you order the results by event time, you cannot specify the
-- @logStreamNamePrefix@ parameter.
--
-- @lastEventTimestamp@ represents 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.
-- @lastEventTimestamp@ updates on an eventual consistency basis. It
-- typically updates in less than an hour from ingestion, but in rare
-- situations might take longer.
--
-- 'descending', 'describeLogStreams_descending' - If the value is true, results are returned in descending order. If the
-- value is to false, results are returned in ascending order. The default
-- value is false.
--
-- 'nextToken', 'describeLogStreams_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'logStreamNamePrefix', 'describeLogStreams_logStreamNamePrefix' - The prefix to match.
--
-- If @orderBy@ is @LastEventTime@, you cannot specify this parameter.
--
-- 'limit', 'describeLogStreams_limit' - The maximum number of items returned. If you don\'t specify a value, the
-- default is up to 50 items.
--
-- 'logGroupName', 'describeLogStreams_logGroupName' - The name of the log group.
newDescribeLogStreams ::
  -- | 'logGroupName'
  Prelude.Text ->
  DescribeLogStreams
newDescribeLogStreams :: Text -> DescribeLogStreams
newDescribeLogStreams Text
pLogGroupName_ =
  DescribeLogStreams' :: Maybe OrderBy
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> DescribeLogStreams
DescribeLogStreams'
    { $sel:orderBy:DescribeLogStreams' :: Maybe OrderBy
orderBy = Maybe OrderBy
forall a. Maybe a
Prelude.Nothing,
      $sel:descending:DescribeLogStreams' :: Maybe Bool
descending = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeLogStreams' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logStreamNamePrefix:DescribeLogStreams' :: Maybe Text
logStreamNamePrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeLogStreams' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:logGroupName:DescribeLogStreams' :: Text
logGroupName = Text
pLogGroupName_
    }

-- | If the value is @LogStreamName@, the results are ordered by log stream
-- name. If the value is @LastEventTime@, the results are ordered by the
-- event time. The default value is @LogStreamName@.
--
-- If you order the results by event time, you cannot specify the
-- @logStreamNamePrefix@ parameter.
--
-- @lastEventTimestamp@ represents 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.
-- @lastEventTimestamp@ updates on an eventual consistency basis. It
-- typically updates in less than an hour from ingestion, but in rare
-- situations might take longer.
describeLogStreams_orderBy :: Lens.Lens' DescribeLogStreams (Prelude.Maybe OrderBy)
describeLogStreams_orderBy :: (Maybe OrderBy -> f (Maybe OrderBy))
-> DescribeLogStreams -> f DescribeLogStreams
describeLogStreams_orderBy = (DescribeLogStreams -> Maybe OrderBy)
-> (DescribeLogStreams -> Maybe OrderBy -> DescribeLogStreams)
-> Lens
     DescribeLogStreams
     DescribeLogStreams
     (Maybe OrderBy)
     (Maybe OrderBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogStreams' {Maybe OrderBy
orderBy :: Maybe OrderBy
$sel:orderBy:DescribeLogStreams' :: DescribeLogStreams -> Maybe OrderBy
orderBy} -> Maybe OrderBy
orderBy) (\s :: DescribeLogStreams
s@DescribeLogStreams' {} Maybe OrderBy
a -> DescribeLogStreams
s {$sel:orderBy:DescribeLogStreams' :: Maybe OrderBy
orderBy = Maybe OrderBy
a} :: DescribeLogStreams)

-- | If the value is true, results are returned in descending order. If the
-- value is to false, results are returned in ascending order. The default
-- value is false.
describeLogStreams_descending :: Lens.Lens' DescribeLogStreams (Prelude.Maybe Prelude.Bool)
describeLogStreams_descending :: (Maybe Bool -> f (Maybe Bool))
-> DescribeLogStreams -> f DescribeLogStreams
describeLogStreams_descending = (DescribeLogStreams -> Maybe Bool)
-> (DescribeLogStreams -> Maybe Bool -> DescribeLogStreams)
-> Lens
     DescribeLogStreams DescribeLogStreams (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogStreams' {Maybe Bool
descending :: Maybe Bool
$sel:descending:DescribeLogStreams' :: DescribeLogStreams -> Maybe Bool
descending} -> Maybe Bool
descending) (\s :: DescribeLogStreams
s@DescribeLogStreams' {} Maybe Bool
a -> DescribeLogStreams
s {$sel:descending:DescribeLogStreams' :: Maybe Bool
descending = Maybe Bool
a} :: DescribeLogStreams)

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

-- | The prefix to match.
--
-- If @orderBy@ is @LastEventTime@, you cannot specify this parameter.
describeLogStreams_logStreamNamePrefix :: Lens.Lens' DescribeLogStreams (Prelude.Maybe Prelude.Text)
describeLogStreams_logStreamNamePrefix :: (Maybe Text -> f (Maybe Text))
-> DescribeLogStreams -> f DescribeLogStreams
describeLogStreams_logStreamNamePrefix = (DescribeLogStreams -> Maybe Text)
-> (DescribeLogStreams -> Maybe Text -> DescribeLogStreams)
-> Lens
     DescribeLogStreams DescribeLogStreams (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogStreams' {Maybe Text
logStreamNamePrefix :: Maybe Text
$sel:logStreamNamePrefix:DescribeLogStreams' :: DescribeLogStreams -> Maybe Text
logStreamNamePrefix} -> Maybe Text
logStreamNamePrefix) (\s :: DescribeLogStreams
s@DescribeLogStreams' {} Maybe Text
a -> DescribeLogStreams
s {$sel:logStreamNamePrefix:DescribeLogStreams' :: Maybe Text
logStreamNamePrefix = Maybe Text
a} :: DescribeLogStreams)

-- | The maximum number of items returned. If you don\'t specify a value, the
-- default is up to 50 items.
describeLogStreams_limit :: Lens.Lens' DescribeLogStreams (Prelude.Maybe Prelude.Natural)
describeLogStreams_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribeLogStreams -> f DescribeLogStreams
describeLogStreams_limit = (DescribeLogStreams -> Maybe Natural)
-> (DescribeLogStreams -> Maybe Natural -> DescribeLogStreams)
-> Lens
     DescribeLogStreams
     DescribeLogStreams
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogStreams' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeLogStreams' :: DescribeLogStreams -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeLogStreams
s@DescribeLogStreams' {} Maybe Natural
a -> DescribeLogStreams
s {$sel:limit:DescribeLogStreams' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeLogStreams)

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

instance Core.AWSPager DescribeLogStreams where
  page :: DescribeLogStreams
-> AWSResponse DescribeLogStreams -> Maybe DescribeLogStreams
page DescribeLogStreams
rq AWSResponse DescribeLogStreams
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeLogStreams
DescribeLogStreamsResponse
rs
            DescribeLogStreamsResponse
-> Getting (First Text) DescribeLogStreamsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeLogStreamsResponse
-> Const (First Text) DescribeLogStreamsResponse
Lens' DescribeLogStreamsResponse (Maybe Text)
describeLogStreamsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeLogStreamsResponse
 -> Const (First Text) DescribeLogStreamsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeLogStreamsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeLogStreams
forall a. Maybe a
Prelude.Nothing
    | Maybe [LogStream] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeLogStreams
DescribeLogStreamsResponse
rs
            DescribeLogStreamsResponse
-> Getting
     (First [LogStream]) DescribeLogStreamsResponse [LogStream]
-> Maybe [LogStream]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [LogStream]
 -> Const (First [LogStream]) (Maybe [LogStream]))
-> DescribeLogStreamsResponse
-> Const (First [LogStream]) DescribeLogStreamsResponse
Lens' DescribeLogStreamsResponse (Maybe [LogStream])
describeLogStreamsResponse_logStreams
              ((Maybe [LogStream]
  -> Const (First [LogStream]) (Maybe [LogStream]))
 -> DescribeLogStreamsResponse
 -> Const (First [LogStream]) DescribeLogStreamsResponse)
-> (([LogStream] -> Const (First [LogStream]) [LogStream])
    -> Maybe [LogStream]
    -> Const (First [LogStream]) (Maybe [LogStream]))
-> Getting
     (First [LogStream]) DescribeLogStreamsResponse [LogStream]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([LogStream] -> Const (First [LogStream]) [LogStream])
-> Maybe [LogStream]
-> Const (First [LogStream]) (Maybe [LogStream])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeLogStreams
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeLogStreams -> Maybe DescribeLogStreams
forall a. a -> Maybe a
Prelude.Just (DescribeLogStreams -> Maybe DescribeLogStreams)
-> DescribeLogStreams -> Maybe DescribeLogStreams
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeLogStreams
rq
          DescribeLogStreams
-> (DescribeLogStreams -> DescribeLogStreams) -> DescribeLogStreams
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeLogStreams -> Identity DescribeLogStreams
Lens
  DescribeLogStreams DescribeLogStreams (Maybe Text) (Maybe Text)
describeLogStreams_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeLogStreams -> Identity DescribeLogStreams)
-> Maybe Text -> DescribeLogStreams -> DescribeLogStreams
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeLogStreams
DescribeLogStreamsResponse
rs
          DescribeLogStreamsResponse
-> Getting (First Text) DescribeLogStreamsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeLogStreamsResponse
-> Const (First Text) DescribeLogStreamsResponse
Lens' DescribeLogStreamsResponse (Maybe Text)
describeLogStreamsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeLogStreamsResponse
 -> Const (First Text) DescribeLogStreamsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeLogStreamsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeLogStreams where
  type
    AWSResponse DescribeLogStreams =
      DescribeLogStreamsResponse
  request :: DescribeLogStreams -> Request DescribeLogStreams
request = Service -> DescribeLogStreams -> Request DescribeLogStreams
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeLogStreams
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeLogStreams)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeLogStreams))
-> Logger
-> Service
-> Proxy DescribeLogStreams
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeLogStreams)))
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 [LogStream] -> Int -> DescribeLogStreamsResponse
DescribeLogStreamsResponse'
            (Maybe Text
 -> Maybe [LogStream] -> Int -> DescribeLogStreamsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [LogStream] -> Int -> DescribeLogStreamsResponse)
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
"nextToken")
            Either
  String (Maybe [LogStream] -> Int -> DescribeLogStreamsResponse)
-> Either String (Maybe [LogStream])
-> Either String (Int -> DescribeLogStreamsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [LogStream]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"logStreams" Either String (Maybe (Maybe [LogStream]))
-> Maybe [LogStream] -> Either String (Maybe [LogStream])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [LogStream]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DescribeLogStreamsResponse)
-> Either String Int -> Either String DescribeLogStreamsResponse
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 DescribeLogStreams

instance Prelude.NFData DescribeLogStreams

instance Core.ToHeaders DescribeLogStreams where
  toHeaders :: DescribeLogStreams -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeLogStreams -> 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.DescribeLogStreams" ::
                          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 DescribeLogStreams where
  toJSON :: DescribeLogStreams -> Value
toJSON DescribeLogStreams' {Maybe Bool
Maybe Natural
Maybe Text
Maybe OrderBy
Text
logGroupName :: Text
limit :: Maybe Natural
logStreamNamePrefix :: Maybe Text
nextToken :: Maybe Text
descending :: Maybe Bool
orderBy :: Maybe OrderBy
$sel:logGroupName:DescribeLogStreams' :: DescribeLogStreams -> Text
$sel:limit:DescribeLogStreams' :: DescribeLogStreams -> Maybe Natural
$sel:logStreamNamePrefix:DescribeLogStreams' :: DescribeLogStreams -> Maybe Text
$sel:nextToken:DescribeLogStreams' :: DescribeLogStreams -> Maybe Text
$sel:descending:DescribeLogStreams' :: DescribeLogStreams -> Maybe Bool
$sel:orderBy:DescribeLogStreams' :: DescribeLogStreams -> Maybe OrderBy
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"orderBy" Text -> OrderBy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OrderBy -> Pair) -> Maybe OrderBy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OrderBy
orderBy,
            (Text
"descending" 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
descending,
            (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
"logStreamNamePrefix" 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
logStreamNamePrefix,
            (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)
          ]
      )

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

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

-- | /See:/ 'newDescribeLogStreamsResponse' smart constructor.
data DescribeLogStreamsResponse = DescribeLogStreamsResponse'
  { DescribeLogStreamsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The log streams.
    DescribeLogStreamsResponse -> Maybe [LogStream]
logStreams :: Prelude.Maybe [LogStream],
    -- | The response's http status code.
    DescribeLogStreamsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeLogStreamsResponse -> DescribeLogStreamsResponse -> Bool
(DescribeLogStreamsResponse -> DescribeLogStreamsResponse -> Bool)
-> (DescribeLogStreamsResponse
    -> DescribeLogStreamsResponse -> Bool)
-> Eq DescribeLogStreamsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLogStreamsResponse -> DescribeLogStreamsResponse -> Bool
$c/= :: DescribeLogStreamsResponse -> DescribeLogStreamsResponse -> Bool
== :: DescribeLogStreamsResponse -> DescribeLogStreamsResponse -> Bool
$c== :: DescribeLogStreamsResponse -> DescribeLogStreamsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeLogStreamsResponse]
ReadPrec DescribeLogStreamsResponse
Int -> ReadS DescribeLogStreamsResponse
ReadS [DescribeLogStreamsResponse]
(Int -> ReadS DescribeLogStreamsResponse)
-> ReadS [DescribeLogStreamsResponse]
-> ReadPrec DescribeLogStreamsResponse
-> ReadPrec [DescribeLogStreamsResponse]
-> Read DescribeLogStreamsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLogStreamsResponse]
$creadListPrec :: ReadPrec [DescribeLogStreamsResponse]
readPrec :: ReadPrec DescribeLogStreamsResponse
$creadPrec :: ReadPrec DescribeLogStreamsResponse
readList :: ReadS [DescribeLogStreamsResponse]
$creadList :: ReadS [DescribeLogStreamsResponse]
readsPrec :: Int -> ReadS DescribeLogStreamsResponse
$creadsPrec :: Int -> ReadS DescribeLogStreamsResponse
Prelude.Read, Int -> DescribeLogStreamsResponse -> ShowS
[DescribeLogStreamsResponse] -> ShowS
DescribeLogStreamsResponse -> String
(Int -> DescribeLogStreamsResponse -> ShowS)
-> (DescribeLogStreamsResponse -> String)
-> ([DescribeLogStreamsResponse] -> ShowS)
-> Show DescribeLogStreamsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLogStreamsResponse] -> ShowS
$cshowList :: [DescribeLogStreamsResponse] -> ShowS
show :: DescribeLogStreamsResponse -> String
$cshow :: DescribeLogStreamsResponse -> String
showsPrec :: Int -> DescribeLogStreamsResponse -> ShowS
$cshowsPrec :: Int -> DescribeLogStreamsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeLogStreamsResponse -> Rep DescribeLogStreamsResponse x)
-> (forall x.
    Rep DescribeLogStreamsResponse x -> DescribeLogStreamsResponse)
-> Generic DescribeLogStreamsResponse
forall x.
Rep DescribeLogStreamsResponse x -> DescribeLogStreamsResponse
forall x.
DescribeLogStreamsResponse -> Rep DescribeLogStreamsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeLogStreamsResponse x -> DescribeLogStreamsResponse
$cfrom :: forall x.
DescribeLogStreamsResponse -> Rep DescribeLogStreamsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLogStreamsResponse' 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:
--
-- 'nextToken', 'describeLogStreamsResponse_nextToken' - Undocumented member.
--
-- 'logStreams', 'describeLogStreamsResponse_logStreams' - The log streams.
--
-- 'httpStatus', 'describeLogStreamsResponse_httpStatus' - The response's http status code.
newDescribeLogStreamsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeLogStreamsResponse
newDescribeLogStreamsResponse :: Int -> DescribeLogStreamsResponse
newDescribeLogStreamsResponse Int
pHttpStatus_ =
  DescribeLogStreamsResponse' :: Maybe Text
-> Maybe [LogStream] -> Int -> DescribeLogStreamsResponse
DescribeLogStreamsResponse'
    { $sel:nextToken:DescribeLogStreamsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logStreams:DescribeLogStreamsResponse' :: Maybe [LogStream]
logStreams = Maybe [LogStream]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeLogStreamsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
describeLogStreamsResponse_nextToken :: Lens.Lens' DescribeLogStreamsResponse (Prelude.Maybe Prelude.Text)
describeLogStreamsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeLogStreamsResponse -> f DescribeLogStreamsResponse
describeLogStreamsResponse_nextToken = (DescribeLogStreamsResponse -> Maybe Text)
-> (DescribeLogStreamsResponse
    -> Maybe Text -> DescribeLogStreamsResponse)
-> Lens' DescribeLogStreamsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogStreamsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeLogStreamsResponse' :: DescribeLogStreamsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeLogStreamsResponse
s@DescribeLogStreamsResponse' {} Maybe Text
a -> DescribeLogStreamsResponse
s {$sel:nextToken:DescribeLogStreamsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeLogStreamsResponse)

-- | The log streams.
describeLogStreamsResponse_logStreams :: Lens.Lens' DescribeLogStreamsResponse (Prelude.Maybe [LogStream])
describeLogStreamsResponse_logStreams :: (Maybe [LogStream] -> f (Maybe [LogStream]))
-> DescribeLogStreamsResponse -> f DescribeLogStreamsResponse
describeLogStreamsResponse_logStreams = (DescribeLogStreamsResponse -> Maybe [LogStream])
-> (DescribeLogStreamsResponse
    -> Maybe [LogStream] -> DescribeLogStreamsResponse)
-> Lens' DescribeLogStreamsResponse (Maybe [LogStream])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogStreamsResponse' {Maybe [LogStream]
logStreams :: Maybe [LogStream]
$sel:logStreams:DescribeLogStreamsResponse' :: DescribeLogStreamsResponse -> Maybe [LogStream]
logStreams} -> Maybe [LogStream]
logStreams) (\s :: DescribeLogStreamsResponse
s@DescribeLogStreamsResponse' {} Maybe [LogStream]
a -> DescribeLogStreamsResponse
s {$sel:logStreams:DescribeLogStreamsResponse' :: Maybe [LogStream]
logStreams = Maybe [LogStream]
a} :: DescribeLogStreamsResponse) ((Maybe [LogStream] -> f (Maybe [LogStream]))
 -> DescribeLogStreamsResponse -> f DescribeLogStreamsResponse)
-> ((Maybe [LogStream] -> f (Maybe [LogStream]))
    -> Maybe [LogStream] -> f (Maybe [LogStream]))
-> (Maybe [LogStream] -> f (Maybe [LogStream]))
-> DescribeLogStreamsResponse
-> f DescribeLogStreamsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [LogStream] [LogStream] [LogStream] [LogStream]
-> Iso
     (Maybe [LogStream])
     (Maybe [LogStream])
     (Maybe [LogStream])
     (Maybe [LogStream])
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 [LogStream] [LogStream] [LogStream] [LogStream]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeLogStreamsResponse