@@ -24,7 +24,7 @@ use chrono::Utc;
2424use http:: StatusCode ;
2525use serde:: { Deserialize , Serialize } ;
2626use serde_json:: { json, Value } ;
27- use tracing:: debug;
27+ use tracing:: { debug, warn } ;
2828
2929use crate :: {
3030 handlers:: http:: {
@@ -38,6 +38,7 @@ use crate::{
3838 hottier:: { HotTierError , HotTierManager , StreamHotTier } ,
3939 parseable:: { StreamNotFound , PARSEABLE } ,
4040 query:: { error:: ExecuteError , execute, CountsRequest , CountsResponse , QUERY_SESSION } ,
41+ rbac:: { map:: SessionKey , role:: Action , Users } ,
4142 stats,
4243 storage:: { retention:: Retention , StreamInfo , StreamType } ,
4344 utils:: {
@@ -237,11 +238,15 @@ impl PrismDatasetRequest {
237238 /// - `Err(PrismLogstreamError)`: If a critical error occurs during processing
238239 ///
239240 /// # 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
241242 /// 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 > {
243248 if self . streams . is_empty ( ) {
244- return Err ( PrismLogstreamError :: Empty ) ;
249+ self . streams = PARSEABLE . streams . list ( ) ;
245250 }
246251
247252 let mut responses = vec ! [ ] ;
@@ -284,7 +289,7 @@ impl PrismDatasetRequest {
284289 fields : vec ! [ "start_time" . into( ) , "end_time" . into( ) , "count" . into( ) ] ,
285290 records,
286291 } ;
287-
292+
288293 // Retrieve distinct values for source identifiers
289294 // Returns None if fields aren't present or if query fails
290295 let ips = self . get_distinct_entries ( & stream, "p_src_ip" ) . await . ok ( ) ;
@@ -367,8 +372,8 @@ pub enum PrismLogstreamError {
367372 TimeParse ( #[ from] TimeParseError ) ,
368373 #[ error( "Execute: {0}" ) ]
369374 Execute ( #[ from] ExecuteError ) ,
370- #[ error( "Empty Stream List " ) ]
371- Empty ,
375+ #[ error( "Auth: {0} " ) ]
376+ Auth ( # [ from ] actix_web :: Error ) ,
372377}
373378
374379impl actix_web:: ResponseError for PrismLogstreamError {
@@ -381,7 +386,7 @@ impl actix_web::ResponseError for PrismLogstreamError {
381386 PrismLogstreamError :: Query ( _) => StatusCode :: INTERNAL_SERVER_ERROR ,
382387 PrismLogstreamError :: TimeParse ( _) => StatusCode :: NOT_FOUND ,
383388 PrismLogstreamError :: Execute ( _) => StatusCode :: INTERNAL_SERVER_ERROR ,
384- PrismLogstreamError :: Empty => StatusCode :: BAD_REQUEST ,
389+ PrismLogstreamError :: Auth ( _ ) => StatusCode :: UNAUTHORIZED ,
385390 }
386391 }
387392
0 commit comments