Skip to content

Commit

Permalink
Expose safekeeper APIs for creation and deletion (#10478)
Browse files Browse the repository at this point in the history
Add APIs for timeline creation and deletion to the safekeeper client
crate. Going to be used later in #10440.

Split off from #10440.

Part of #9011
  • Loading branch information
arpad-m authored Jan 22, 2025
1 parent f1473dd commit c60b913
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion safekeeper/client/src/mgmt_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! united.
use reqwest::{IntoUrl, Method, StatusCode};
use safekeeper_api::models::TimelineStatus;
use safekeeper_api::models::{TimelineCreateRequest, TimelineStatus};
use std::error::Error as _;
use utils::{
http::error::HttpErrorBody,
Expand Down Expand Up @@ -76,6 +76,28 @@ impl Client {
}
}

pub async fn create_timeline(&self, req: &TimelineCreateRequest) -> Result<TimelineStatus> {
let uri = format!(
"{}/v1/tenant/{}/timeline/{}",
self.mgmt_api_endpoint, req.tenant_id, req.timeline_id
);
let resp = self.post(&uri, req).await?;
resp.json().await.map_err(Error::ReceiveBody)
}

pub async fn delete_timeline(
&self,
tenant_id: TenantId,
timeline_id: TimelineId,
) -> Result<TimelineStatus> {
let uri = format!(
"{}/v1/tenant/{}/timeline/{}",
self.mgmt_api_endpoint, tenant_id, timeline_id
);
let resp = self.request(Method::DELETE, &uri, ()).await?;
resp.json().await.map_err(Error::ReceiveBody)
}

pub async fn timeline_status(
&self,
tenant_id: TenantId,
Expand Down Expand Up @@ -107,6 +129,14 @@ impl Client {
self.get(&uri).await
}

async fn post<B: serde::Serialize, U: IntoUrl>(
&self,
uri: U,
body: B,
) -> Result<reqwest::Response> {
self.request(Method::POST, uri, body).await
}

async fn get<U: IntoUrl>(&self, uri: U) -> Result<reqwest::Response> {
self.request(Method::GET, uri, ()).await
}
Expand Down

1 comment on commit c60b913

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7370 tests run: 6983 passed, 1 failed, 386 skipped (full report)


Failures on Postgres 17

# Run all failed tests locally:
scripts/pytest -vv -n $(nproc) -k "test_scrubber_tenant_snapshot[debug-pg17-4]"
Flaky tests (5)

Postgres 17

Postgres 15

Postgres 14

Test coverage report is not available

The comment gets automatically updated with the latest test results
c60b913 at 2025-01-22T19:50:08.755Z :recycle:

Please sign in to comment.