diff --git a/src/auth/types.rs b/src/auth/types.rs index bed5ad27..b9a61181 100644 --- a/src/auth/types.rs +++ b/src/auth/types.rs @@ -42,55 +42,104 @@ pub struct ClientCredentials { /// Default OAuth scopes requested during login. pub fn default_scopes() -> Vec<&'static str> { vec![ + // APM + "apm_read", + "apm_service_catalog_read", + // Audit + "audit_logs_read", + // Azure + "azure_configuration_read", + // BITS + "bits_investigations_read", + "bits_investigations_write", + // Cases + "cases_read", + "cases_write", + // CI Visibility + "ci_visibility_read", + "code_coverage_read", + "dora_metrics_write", + "test_optimization_read", + "test_optimization_write", + // Dashboards "dashboards_read", "dashboards_write", + // Data Scanner + "data_scanner_read", + // Error Tracking "error_tracking_read", - "monitors_read", - "monitors_write", - "monitors_downtime", - "audit_logs_read", - "apm_read", - "slos_read", - "slos_write", - "slos_corrections", + // Events + "events_read", + // HAMR (disaster recovery) + "disaster_recovery_status_read", + "disaster_recovery_status_write", + // Hosts + "hosts_read", + "host_tags_write", + // Incidents "incident_read", "incident_write", "incident_notification_settings_read", "incident_settings_read", "incident_settings_write", - "synthetics_read", - "synthetics_write", - "synthetics_global_variable_read", - "synthetics_global_variable_write", - "synthetics_private_location_read", - "synthetics_private_location_write", - "security_monitoring_signals_read", - "security_monitoring_rules_read", - "security_monitoring_findings_read", - "security_monitoring_suppressions_read", - "security_monitoring_filters_read", - "rum_apps_read", - "rum_apps_write", - "rum_retention_filters_read", - "rum_retention_filters_write", - "hosts_read", - "user_access_read", - "user_self_profile_read", - "cases_read", - "cases_write", - "events_read", + // Integrations (Jira, ServiceNow, Slack, Webhooks) + "integrations_read", + "manage_integrations", + // Logs "logs_generate_metrics", + "logs_modify_indexes", "logs_read_archives", "logs_read_config", "logs_read_data", "logs_read_index_data", "logs_write_archives", + // Metrics "metrics_read", + // Monitors + "monitors_read", + "monitors_write", + "monitors_downtime", + // Notebooks + "notebooks_read", + "notebooks_write", + // OCI "oci_configuration_edit", "oci_configuration_read", "oci_configurations_manage", + // Organizations + "org_management", + // RUM + "rum_apps_read", + "rum_apps_write", + "rum_generate_metrics", + "rum_retention_filters_read", + "rum_retention_filters_write", + "rum_session_replay_read", + // Security + "security_monitoring_filters_read", + "security_monitoring_filters_write", + "security_monitoring_findings_read", + "security_monitoring_rules_read", + "security_monitoring_rules_write", + "security_monitoring_signals_read", + // SLOs + "slos_read", + "slos_write", + // Status Pages + "status_pages_settings_read", + "status_pages_settings_write", + // Synthetics + "synthetics_read", + "synthetics_write", + "synthetics_private_location_read", + // Teams + "teams_read", + // Timeseries "timeseries_query", + // Usage "usage_read", + // Users + "user_access_read", ] } @@ -137,10 +186,20 @@ mod tests { #[test] fn test_default_scopes() { let scopes = default_scopes(); - assert!(scopes.len() > 20); + assert_eq!(scopes.len(), 69); assert!(scopes.contains(&"dashboards_read")); assert!(scopes.contains(&"monitors_read")); assert!(scopes.contains(&"logs_read_data")); + // Batch 2 additions + assert!(scopes.contains(&"integrations_read")); + assert!(scopes.contains(&"org_management")); + assert!(scopes.contains(&"disaster_recovery_status_read")); + assert!(scopes.contains(&"notebooks_read")); + assert!(scopes.contains(&"rum_generate_metrics")); + assert!(scopes.contains(&"ci_visibility_read")); + assert!(scopes.contains(&"teams_read")); + assert!(scopes.contains(&"apm_service_catalog_read")); + assert!(scopes.contains(&"status_pages_settings_read")); } #[test] diff --git a/src/client.rs b/src/client.rs index e48d72b9..57c366ea 100644 --- a/src/client.rs +++ b/src/client.rs @@ -264,47 +264,6 @@ fn find_endpoint_requirement(method: &str, path: &str) -> Option<&'static Endpoi /// Trailing "/" means prefix match for ID-parameterized paths. #[cfg(not(target_arch = "wasm32"))] static OAUTH_EXCLUDED_ENDPOINTS: &[EndpointRequirement] = &[ - // RUM API (10) - EndpointRequirement { - path: "/api/v2/rum/applications", - method: "GET", - }, - EndpointRequirement { - path: "/api/v2/rum/applications/", - method: "GET", - }, - EndpointRequirement { - path: "/api/v2/rum/applications", - method: "POST", - }, - EndpointRequirement { - path: "/api/v2/rum/applications/", - method: "PATCH", - }, - EndpointRequirement { - path: "/api/v2/rum/applications/", - method: "DELETE", - }, - EndpointRequirement { - path: "/api/v2/rum/metrics", - method: "GET", - }, - EndpointRequirement { - path: "/api/v2/rum/metrics/", - method: "GET", - }, - EndpointRequirement { - path: "/api/v2/rum/retention_filters", - method: "GET", - }, - EndpointRequirement { - path: "/api/v2/rum/retention_filters/", - method: "GET", - }, - EndpointRequirement { - path: "/api/v2/rum/events/search", - method: "POST", - }, // API/App Keys (8) EndpointRequirement { path: "/api/v2/api_keys", @@ -342,11 +301,6 @@ static OAUTH_EXCLUDED_ENDPOINTS: &[EndpointRequirement] = &[ path: "/api/v2/application_keys/", method: "DELETE", }, - // Events (1) - EndpointRequirement { - path: "/api/v2/events/search", - method: "POST", - }, // Fleet Automation (15) EndpointRequirement { path: "/api/v2/fleet/agents", @@ -408,27 +362,6 @@ static OAUTH_EXCLUDED_ENDPOINTS: &[EndpointRequirement] = &[ path: "/api/v2/fleet/schedules/", method: "POST", }, - // Notebooks (5) - EndpointRequirement { - path: "/api/v1/notebooks", - method: "GET", - }, - EndpointRequirement { - path: "/api/v1/notebooks", - method: "POST", - }, - EndpointRequirement { - path: "/api/v1/notebooks/", - method: "GET", - }, - EndpointRequirement { - path: "/api/v1/notebooks/", - method: "PUT", - }, - EndpointRequirement { - path: "/api/v1/notebooks/", - method: "DELETE", - }, ]; // --------------------------------------------------------------------------- @@ -557,17 +490,20 @@ mod tests { } #[test] - fn test_requires_api_key_fallback_rum() { - assert!(requires_api_key_fallback("GET", "/api/v2/rum/applications")); - assert!(requires_api_key_fallback( + fn test_no_fallback_for_rum() { + assert!(!requires_api_key_fallback( + "GET", + "/api/v2/rum/applications" + )); + assert!(!requires_api_key_fallback( "GET", "/api/v2/rum/applications/abc-123" )); } #[test] - fn test_requires_api_key_fallback_events() { - assert!(requires_api_key_fallback("POST", "/api/v2/events/search")); + fn test_no_fallback_for_events_search() { + assert!(!requires_api_key_fallback("POST", "/api/v2/events/search")); } #[test] @@ -580,14 +516,14 @@ mod tests { #[test] fn test_prefix_matching_with_id() { // Trailing "/" in the pattern should match paths with IDs - assert!(requires_api_key_fallback( - "GET", - "/api/v2/rum/applications/some-uuid-here" - )); assert!(requires_api_key_fallback( "DELETE", "/api/v2/api_keys/key-123" )); + assert!(requires_api_key_fallback( + "GET", + "/api/v2/fleet/agents/agent-123" + )); } #[test] @@ -606,7 +542,7 @@ mod tests { #[test] fn test_oauth_excluded_count() { - assert_eq!(OAUTH_EXCLUDED_ENDPOINTS.len(), 40); + assert_eq!(OAUTH_EXCLUDED_ENDPOINTS.len(), 24); } #[test] @@ -675,10 +611,10 @@ mod tests { } #[test] - fn test_requires_api_key_fallback_notebooks() { - assert!(requires_api_key_fallback("GET", "/api/v1/notebooks")); - assert!(requires_api_key_fallback("GET", "/api/v1/notebooks/12345")); - assert!(requires_api_key_fallback("POST", "/api/v1/notebooks")); + fn test_no_fallback_for_notebooks() { + assert!(!requires_api_key_fallback("GET", "/api/v1/notebooks")); + assert!(!requires_api_key_fallback("GET", "/api/v1/notebooks/12345")); + assert!(!requires_api_key_fallback("POST", "/api/v1/notebooks")); } #[test] diff --git a/src/commands/events.rs b/src/commands/events.rs index 52a1b192..ec9ef2ab 100644 --- a/src/commands/events.rs +++ b/src/commands/events.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Result}; +use anyhow::Result; #[cfg(not(target_arch = "wasm32"))] use datadog_api_client::datadogV1::api_events::{ EventsAPI as EventsV1API, ListEventsOptionalParams, @@ -65,16 +65,11 @@ pub async fn search( to: String, limit: i32, ) -> Result<()> { - // Events search is OAuth-excluded — require API keys - if !cfg.has_api_keys() { - bail!( - "events search requires API key authentication (DD_API_KEY + DD_APP_KEY).\n\ - This endpoint does not support bearer token auth." - ); - } - let dd_cfg = client::make_dd_config(cfg); - let api = EventsV2API::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => EventsV2API::with_client_and_config(dd_cfg, c), + None => EventsV2API::with_config(dd_cfg), + }; let from_ms = util::parse_time_to_unix_millis(&from)?; let to_ms = util::parse_time_to_unix_millis(&to)?; diff --git a/src/commands/rum.rs b/src/commands/rum.rs index bb4186a7..1535c310 100644 --- a/src/commands/rum.rs +++ b/src/commands/rum.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Result}; +use anyhow::Result; #[cfg(not(target_arch = "wasm32"))] use datadog_api_client::datadogV2::api_rum::{ListRUMEventsOptionalParams, RUMAPI}; #[cfg(not(target_arch = "wasm32"))] @@ -30,12 +30,11 @@ use crate::util; #[cfg(not(target_arch = "wasm32"))] pub async fn apps_list(cfg: &Config) -> Result<()> { - // RUM apps is OAuth-excluded — require API keys - if !cfg.has_api_keys() { - bail!("RUM apps requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RUMAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RUMAPI::with_client_and_config(dd_cfg, c), + None => RUMAPI::with_config(dd_cfg), + }; let resp = api .get_rum_applications() .await @@ -51,11 +50,11 @@ pub async fn apps_list(cfg: &Config) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn apps_get(cfg: &Config, app_id: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM apps requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RUMAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RUMAPI::with_client_and_config(dd_cfg, c), + None => RUMAPI::with_config(dd_cfg), + }; let resp = api .get_rum_application(app_id.to_string()) .await @@ -72,11 +71,11 @@ pub async fn apps_get(cfg: &Config, app_id: &str) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn apps_create(cfg: &Config, name: &str, app_type: Option) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM apps requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RUMAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RUMAPI::with_client_and_config(dd_cfg, c), + None => RUMAPI::with_config(dd_cfg), + }; let mut attrs = RUMApplicationCreateAttributes::new(name.to_string()); if let Some(t) = app_type { attrs = attrs.type_(t); @@ -108,11 +107,11 @@ pub async fn apps_create(cfg: &Config, name: &str, app_type: Option) -> #[cfg(not(target_arch = "wasm32"))] pub async fn apps_delete(cfg: &Config, app_id: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM apps requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RUMAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RUMAPI::with_client_and_config(dd_cfg, c), + None => RUMAPI::with_config(dd_cfg), + }; api.delete_rum_application(app_id.to_string()) .await .map_err(|e| anyhow::anyhow!("failed to delete RUM app: {e:?}"))?; @@ -239,11 +238,11 @@ pub async fn sessions_search( #[cfg(not(target_arch = "wasm32"))] pub async fn apps_update(cfg: &Config, app_id: &str, file: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM apps requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RUMAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RUMAPI::with_client_and_config(dd_cfg, c), + None => RUMAPI::with_config(dd_cfg), + }; let body: RUMApplicationUpdateRequest = crate::util::read_json_file(file)?; let resp = api .update_rum_application(app_id.to_string(), body) @@ -264,11 +263,11 @@ pub async fn apps_update(cfg: &Config, app_id: &str, file: &str) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn metrics_list(cfg: &Config) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM metrics requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumMetricsAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumMetricsAPI::with_client_and_config(dd_cfg, c), + None => RumMetricsAPI::with_config(dd_cfg), + }; let resp = api .list_rum_metrics() .await @@ -284,11 +283,11 @@ pub async fn metrics_list(cfg: &Config) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn metrics_get(cfg: &Config, metric_id: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM metrics requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumMetricsAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumMetricsAPI::with_client_and_config(dd_cfg, c), + None => RumMetricsAPI::with_config(dd_cfg), + }; let resp = api .get_rum_metric(metric_id.to_string()) .await @@ -305,11 +304,11 @@ pub async fn metrics_get(cfg: &Config, metric_id: &str) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn metrics_create(cfg: &Config, file: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM metrics requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumMetricsAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumMetricsAPI::with_client_and_config(dd_cfg, c), + None => RumMetricsAPI::with_config(dd_cfg), + }; let body: RumMetricCreateRequest = crate::util::read_json_file(file)?; let resp = api .create_rum_metric(body) @@ -327,11 +326,11 @@ pub async fn metrics_create(cfg: &Config, file: &str) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn metrics_update(cfg: &Config, metric_id: &str, file: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM metrics requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumMetricsAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumMetricsAPI::with_client_and_config(dd_cfg, c), + None => RumMetricsAPI::with_config(dd_cfg), + }; let body: RumMetricUpdateRequest = crate::util::read_json_file(file)?; let resp = api .update_rum_metric(metric_id.to_string(), body) @@ -350,11 +349,11 @@ pub async fn metrics_update(cfg: &Config, metric_id: &str, file: &str) -> Result #[cfg(not(target_arch = "wasm32"))] pub async fn metrics_delete(cfg: &Config, metric_id: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM metrics requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumMetricsAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumMetricsAPI::with_client_and_config(dd_cfg, c), + None => RumMetricsAPI::with_config(dd_cfg), + }; api.delete_rum_metric(metric_id.to_string()) .await .map_err(|e| anyhow::anyhow!("failed to delete RUM metric: {e:?}"))?; @@ -374,11 +373,11 @@ pub async fn metrics_delete(cfg: &Config, metric_id: &str) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn retention_filters_list(cfg: &Config, app_id: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM retention filters requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumRetentionFiltersAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumRetentionFiltersAPI::with_client_and_config(dd_cfg, c), + None => RumRetentionFiltersAPI::with_config(dd_cfg), + }; let resp = api .list_retention_filters(app_id.to_string()) .await @@ -395,11 +394,11 @@ pub async fn retention_filters_list(cfg: &Config, app_id: &str) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn retention_filters_get(cfg: &Config, app_id: &str, filter_id: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM retention filters requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumRetentionFiltersAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumRetentionFiltersAPI::with_client_and_config(dd_cfg, c), + None => RumRetentionFiltersAPI::with_config(dd_cfg), + }; let resp = api .get_retention_filter(app_id.to_string(), filter_id.to_string()) .await @@ -416,11 +415,11 @@ pub async fn retention_filters_get(cfg: &Config, app_id: &str, filter_id: &str) #[cfg(not(target_arch = "wasm32"))] pub async fn retention_filters_create(cfg: &Config, app_id: &str, file: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM retention filters requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumRetentionFiltersAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumRetentionFiltersAPI::with_client_and_config(dd_cfg, c), + None => RumRetentionFiltersAPI::with_config(dd_cfg), + }; let body: RumRetentionFilterCreateRequest = crate::util::read_json_file(file)?; let resp = api .create_retention_filter(app_id.to_string(), body) @@ -444,11 +443,11 @@ pub async fn retention_filters_update( filter_id: &str, file: &str, ) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM retention filters requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumRetentionFiltersAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumRetentionFiltersAPI::with_client_and_config(dd_cfg, c), + None => RumRetentionFiltersAPI::with_config(dd_cfg), + }; let body: RumRetentionFilterUpdateRequest = crate::util::read_json_file(file)?; let resp = api .update_retention_filter(app_id.to_string(), filter_id.to_string(), body) @@ -472,11 +471,11 @@ pub async fn retention_filters_update( #[cfg(not(target_arch = "wasm32"))] pub async fn retention_filters_delete(cfg: &Config, app_id: &str, filter_id: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM retention filters requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumRetentionFiltersAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumRetentionFiltersAPI::with_client_and_config(dd_cfg, c), + None => RumRetentionFiltersAPI::with_config(dd_cfg), + }; api.delete_retention_filter(app_id.to_string(), filter_id.to_string()) .await .map_err(|e| anyhow::anyhow!("failed to delete RUM retention filter: {e:?}"))?; @@ -555,11 +554,11 @@ pub async fn sessions_list(cfg: &Config, from: String, to: String, limit: i32) - #[cfg(not(target_arch = "wasm32"))] pub async fn playlists_list(cfg: &Config) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM playlists requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumReplayPlaylistsAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumReplayPlaylistsAPI::with_client_and_config(dd_cfg, c), + None => RumReplayPlaylistsAPI::with_config(dd_cfg), + }; let resp = api .list_rum_replay_playlists(ListRumReplayPlaylistsOptionalParams::default()) .await @@ -575,11 +574,11 @@ pub async fn playlists_list(cfg: &Config) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn playlists_get(cfg: &Config, playlist_id: i32) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM playlists requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumReplayPlaylistsAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumReplayPlaylistsAPI::with_client_and_config(dd_cfg, c), + None => RumReplayPlaylistsAPI::with_config(dd_cfg), + }; let resp = api .get_rum_replay_playlist(playlist_id) .await @@ -598,11 +597,11 @@ pub async fn playlists_get(cfg: &Config, playlist_id: i32) -> Result<()> { #[cfg(not(target_arch = "wasm32"))] pub async fn heatmaps_query(cfg: &Config, view_name: &str) -> Result<()> { - if !cfg.has_api_keys() { - bail!("RUM heatmaps requires API key authentication (DD_API_KEY + DD_APP_KEY)"); - } let dd_cfg = client::make_dd_config(cfg); - let api = RumReplayHeatmapsAPI::with_config(dd_cfg); + let api = match client::make_bearer_client(cfg) { + Some(c) => RumReplayHeatmapsAPI::with_client_and_config(dd_cfg, c), + None => RumReplayHeatmapsAPI::with_config(dd_cfg), + }; let resp = api .list_replay_heatmap_snapshots( view_name.to_string(), diff --git a/src/main.rs b/src/main.rs index ebd31fb0..04cb4368 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5996,104 +5996,85 @@ async fn main_inner() -> anyhow::Result<()> { } // --- Status Pages --- Commands::StatusPages { action } => match action { - StatusPageActions::Pages { action } => { - cfg.validate_api_and_app_keys()?; - match action { - StatusPagePageActions::List => commands::status_pages::pages_list(&cfg).await?, - StatusPagePageActions::Get { page_id } => { - commands::status_pages::pages_get(&cfg, &page_id).await?; - } - StatusPagePageActions::Create { file } => { - commands::status_pages::pages_create(&cfg, &file).await?; - } - StatusPagePageActions::Update { page_id, file } => { - commands::status_pages::pages_update(&cfg, &page_id, &file).await?; - } - StatusPagePageActions::Delete { page_id } => { - commands::status_pages::pages_delete(&cfg, &page_id).await?; - } + StatusPageActions::Pages { action } => match action { + StatusPagePageActions::List => commands::status_pages::pages_list(&cfg).await?, + StatusPagePageActions::Get { page_id } => { + commands::status_pages::pages_get(&cfg, &page_id).await?; } - } - StatusPageActions::Components { action } => { - cfg.validate_api_and_app_keys()?; - match action { - StatusPageComponentActions::List { page_id } => { - commands::status_pages::components_list(&cfg, &page_id).await?; - } - StatusPageComponentActions::Get { - page_id, - component_id, - } => { - commands::status_pages::components_get(&cfg, &page_id, &component_id) - .await?; - } - StatusPageComponentActions::Create { page_id, file } => { - commands::status_pages::components_create(&cfg, &page_id, &file).await?; - } - StatusPageComponentActions::Update { - page_id, - component_id, - file, - } => { - commands::status_pages::components_update( - &cfg, - &page_id, - &component_id, - &file, - ) + StatusPagePageActions::Create { file } => { + commands::status_pages::pages_create(&cfg, &file).await?; + } + StatusPagePageActions::Update { page_id, file } => { + commands::status_pages::pages_update(&cfg, &page_id, &file).await?; + } + StatusPagePageActions::Delete { page_id } => { + commands::status_pages::pages_delete(&cfg, &page_id).await?; + } + }, + StatusPageActions::Components { action } => match action { + StatusPageComponentActions::List { page_id } => { + commands::status_pages::components_list(&cfg, &page_id).await?; + } + StatusPageComponentActions::Get { + page_id, + component_id, + } => { + commands::status_pages::components_get(&cfg, &page_id, &component_id).await?; + } + StatusPageComponentActions::Create { page_id, file } => { + commands::status_pages::components_create(&cfg, &page_id, &file).await?; + } + StatusPageComponentActions::Update { + page_id, + component_id, + file, + } => { + commands::status_pages::components_update(&cfg, &page_id, &component_id, &file) .await?; - } - StatusPageComponentActions::Delete { - page_id, - component_id, - } => { - commands::status_pages::components_delete(&cfg, &page_id, &component_id) - .await?; - } } - } - StatusPageActions::Degradations { action } => { - cfg.validate_api_and_app_keys()?; - match action { - StatusPageDegradationActions::List => { - commands::status_pages::degradations_list(&cfg).await?; - } - StatusPageDegradationActions::Get { - page_id, - degradation_id, - } => { - commands::status_pages::degradations_get(&cfg, &page_id, °radation_id) - .await?; - } - StatusPageDegradationActions::Create { page_id, file } => { - commands::status_pages::degradations_create(&cfg, &page_id, &file).await?; - } - StatusPageDegradationActions::Update { - page_id, - degradation_id, - file, - } => { - commands::status_pages::degradations_update( - &cfg, - &page_id, - °radation_id, - &file, - ) + StatusPageComponentActions::Delete { + page_id, + component_id, + } => { + commands::status_pages::components_delete(&cfg, &page_id, &component_id) .await?; - } - StatusPageDegradationActions::Delete { - page_id, - degradation_id, - } => { - commands::status_pages::degradations_delete( - &cfg, - &page_id, - °radation_id, - ) + } + }, + StatusPageActions::Degradations { action } => match action { + StatusPageDegradationActions::List => { + commands::status_pages::degradations_list(&cfg).await?; + } + StatusPageDegradationActions::Get { + page_id, + degradation_id, + } => { + commands::status_pages::degradations_get(&cfg, &page_id, °radation_id) .await?; - } } - } + StatusPageDegradationActions::Create { page_id, file } => { + commands::status_pages::degradations_create(&cfg, &page_id, &file).await?; + } + StatusPageDegradationActions::Update { + page_id, + degradation_id, + file, + } => { + commands::status_pages::degradations_update( + &cfg, + &page_id, + °radation_id, + &file, + ) + .await?; + } + StatusPageDegradationActions::Delete { + page_id, + degradation_id, + } => { + commands::status_pages::degradations_delete(&cfg, &page_id, °radation_id) + .await?; + } + }, StatusPageActions::ThirdParty { action } => match action { StatusPageThirdPartyActions::List { active, search } => { commands::status_pages::third_party_list(&cfg, search.as_deref(), active)