@@ -24,7 +24,7 @@ use chrono::Utc;
24
24
use http:: StatusCode ;
25
25
use serde:: { Deserialize , Serialize } ;
26
26
use serde_json:: { json, Value } ;
27
- use tracing:: debug;
27
+ use tracing:: { debug, warn } ;
28
28
29
29
use crate :: {
30
30
handlers:: http:: {
@@ -38,6 +38,7 @@ use crate::{
38
38
hottier:: { HotTierError , HotTierManager , StreamHotTier } ,
39
39
parseable:: { StreamNotFound , PARSEABLE } ,
40
40
query:: { error:: ExecuteError , execute, CountsRequest , CountsResponse , QUERY_SESSION } ,
41
+ rbac:: { map:: SessionKey , role:: Action , Users } ,
41
42
stats,
42
43
storage:: { retention:: Retention , StreamInfo , StreamType } ,
43
44
utils:: {
@@ -237,11 +238,15 @@ impl PrismDatasetRequest {
237
238
/// - `Err(PrismLogstreamError)`: If a critical error occurs during processing
238
239
///
239
240
/// # Note
240
- /// This method won't fail if individual streams fail - it will only include
241
+ /// 1. This method won't fail if individual streams fail - it will only include
241
242
/// successfully processed streams in the result.
242
- pub async fn get_datasets ( self ) -> Result < Vec < PrismDatasetResponse > , PrismLogstreamError > {
243
+ /// 2. On receiving an empty stream list, we return for all streams the user is able to query for
244
+ pub async fn get_datasets (
245
+ mut self ,
246
+ key : SessionKey ,
247
+ ) -> Result < Vec < PrismDatasetResponse > , PrismLogstreamError > {
243
248
if self . streams . is_empty ( ) {
244
- return Err ( PrismLogstreamError :: Empty ) ;
249
+ self . streams = PARSEABLE . streams . list ( ) ;
245
250
}
246
251
247
252
let mut responses = vec ! [ ] ;
@@ -284,7 +289,7 @@ impl PrismDatasetRequest {
284
289
fields : vec ! [ "start_time" . into( ) , "end_time" . into( ) , "count" . into( ) ] ,
285
290
records,
286
291
} ;
287
-
292
+
288
293
// Retrieve distinct values for source identifiers
289
294
// Returns None if fields aren't present or if query fails
290
295
let ips = self . get_distinct_entries ( & stream, "p_src_ip" ) . await . ok ( ) ;
@@ -367,8 +372,8 @@ pub enum PrismLogstreamError {
367
372
TimeParse ( #[ from] TimeParseError ) ,
368
373
#[ error( "Execute: {0}" ) ]
369
374
Execute ( #[ from] ExecuteError ) ,
370
- #[ error( "Empty Stream List " ) ]
371
- Empty ,
375
+ #[ error( "Auth: {0} " ) ]
376
+ Auth ( # [ from ] actix_web :: Error ) ,
372
377
}
373
378
374
379
impl actix_web:: ResponseError for PrismLogstreamError {
@@ -381,7 +386,7 @@ impl actix_web::ResponseError for PrismLogstreamError {
381
386
PrismLogstreamError :: Query ( _) => StatusCode :: INTERNAL_SERVER_ERROR ,
382
387
PrismLogstreamError :: TimeParse ( _) => StatusCode :: NOT_FOUND ,
383
388
PrismLogstreamError :: Execute ( _) => StatusCode :: INTERNAL_SERVER_ERROR ,
384
- PrismLogstreamError :: Empty => StatusCode :: BAD_REQUEST ,
389
+ PrismLogstreamError :: Auth ( _ ) => StatusCode :: UNAUTHORIZED ,
385
390
}
386
391
}
387
392
0 commit comments