diff --git a/CHANGELOG.md b/CHANGELOG.md index 1731aaf8..cb7aeaf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ _This paragraph may describe WIP/unreleased features. They are merged to main br ### Changed +- Make _filter tags_ optional in the API routes. + ## [2.0.0]-2024-01-10 ### Added diff --git a/cloud-scanner-cli/src/standalone_server.rs b/cloud-scanner-cli/src/standalone_server.rs index 0b52e0a6..f1837d88 100644 --- a/cloud-scanner-cli/src/standalone_server.rs +++ b/cloud-scanner-cli/src/standalone_server.rs @@ -38,9 +38,9 @@ fn index(config: &State) -> String { /// # Returns Prometheus metrics. /// -/// Region is mandatory, filter_tags can be an empty string (""). +/// Region is mandatory. Filter_tags (if any) should be written as string containing tag_name=tag_value /// -/// Results are estimated for one hour of use by default. +/// Results are estimated for one hour of use by default. /// /// Example query: http://localhost:8000/metrics?aws_region=eu-west-3&filter_tag=Name=boatest&filter_tag=OtherTag=other-value&use_duration_hours=1.0&include_storage=true #[openapi(tag = "metrics")] @@ -48,7 +48,7 @@ fn index(config: &State) -> String { async fn metrics( config: &State, aws_region: &str, - filter_tags: Vec, + filter_tags: Option>, use_duration_hours: Option, include_block_storage: Option, ) -> String { @@ -57,7 +57,7 @@ async fn metrics( warn!("Filtering on tags {:?}", filter_tags); let metrics = crate::get_default_impacts_as_metrics( &hours_use_time, - &filter_tags, + &filter_tags.unwrap_or_default(), aws_region, &config.boavizta_url, include_block_storage.unwrap_or(false), @@ -68,7 +68,7 @@ async fn metrics( /// # Returns the inventory as json. /// -/// Region is mandatory, filter_tags can be an empty string (""). +/// Region is mandatory. Filter_tags (if any) should be written as string containing tag_name=tag_value /// /// Example query: http://localhost:8000/inventorynew?aws_region=eu-west-3&filter_tag=Name=boatest&filter_tag=OtherTag=other-value #[openapi(tag = "inventory")] @@ -76,14 +76,14 @@ async fn metrics( async fn inventory( _config: &State, aws_region: &str, - filter_tags: Vec, + filter_tags: Option>, include_block_storage: Option, ) -> Json { warn!("Getting something on /inventory"); warn!("Filtering on tags {:?}", filter_tags); Json( crate::get_inventory( - &filter_tags, + &filter_tags.unwrap_or_default(), aws_region, include_block_storage.unwrap_or(false), ) @@ -94,7 +94,7 @@ async fn inventory( /// # Returns the impacts (use and embedded) as json. /// -/// Region is mandatory, filter_tags can be an empty string (""). +/// Region is mandatory. Filter_tags (if any) should be written as string containing tag_name=tag_value /// /// Example query: http://localhost:8000/impacts?aws_region=eu-west-3&filter_tag=Name=boatest&filter_tag=OtherTag=other-value&use_duration_hours=1.0 #[openapi(tag = "impacts")] @@ -104,7 +104,7 @@ async fn inventory( async fn impacts( _config: &State, aws_region: &str, - filter_tags: Vec, + filter_tags: Option>, use_duration_hours: Option, verbose_output: Option, include_block_storage: Option, @@ -118,7 +118,7 @@ async fn impacts( warn!("Filtering on tags {:?}", filter_tags); let res = crate::standard_scan( &hours_use_time, - &filter_tags, + &filter_tags.unwrap_or_default(), aws_region, &_config.boavizta_url, verbose_output.unwrap_or(false),