Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/auth/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub fn default_scopes() -> Vec<&'static str> {
// APM
"apm_read",
"apm_service_catalog_read",
"apm_service_renaming_write",
// Audit
"audit_logs_read",
// AWS
Expand Down Expand Up @@ -270,7 +271,7 @@ mod tests {
#[test]
fn test_default_scopes() {
let scopes = default_scopes();
assert_eq!(scopes.len(), 84);
assert_eq!(scopes.len(), 85);
assert!(scopes.contains(&"dashboards_read"));
assert!(scopes.contains(&"monitors_read"));
assert!(scopes.contains(&"logs_read_data"));
Expand All @@ -283,6 +284,7 @@ mod tests {
assert!(scopes.contains(&"ci_visibility_read"));
assert!(scopes.contains(&"teams_read"));
assert!(scopes.contains(&"apm_service_catalog_read"));
assert!(scopes.contains(&"apm_service_renaming_write"));
assert!(scopes.contains(&"status_pages_settings_read"));
assert!(scopes.contains(&"on_call_read"));
assert!(scopes.contains(&"on_call_write"));
Expand Down
27 changes: 27 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,33 @@ pub async fn raw_post_jsonapi(
parse_response_json(resp).await
}

pub async fn raw_put(
cfg: &Config,
path: &str,
body: serde_json::Value,
) -> anyhow::Result<serde_json::Value> {
let url = format!("{}{}", cfg.api_base_url(), path);
let client = reqwest::Client::new();
let req = client.put(&url);
let req = apply_auth(req, cfg, "PUT", path)?;
let resp = req
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("User-Agent", useragent::get())
.json(&body)
.send()
.await?;
if resp.status() == reqwest::StatusCode::NO_CONTENT {
return Ok(serde_json::Value::Null);
}
if !resp.status().is_success() {
let status = resp.status();
let body = resp.text().await.unwrap_or_default();
anyhow::bail!("PUT {url} failed (HTTP {status}): {body}");
}
parse_response_json(resp).await
}

/// Like `raw_post`, but returns the parsed JSON body even on non-2xx responses.
/// Callers are responsible for inspecting the body for errors.
pub async fn raw_post_lenient(
Expand Down
Loading
Loading