| |
.route("/save_embed_by_bytes", post(save_embed_handler))
|
| |
.route("/save_embed_to_disk", post(save_embed_handler))
|
| |
.route("/list_jobs", post(jobs_handler))
|
| + |
.route("/list_releases", post(list_releases_handler))
|
| + |
.route("/release_by_id", post(release_by_id_handler))
|
| + |
.route("/releases_by_commit", post(releases_by_commit_handler))
|
| + |
.route("/compute_artifact_cid", post(compute_artifact_cid_handler))
|
| + |
.route("/create_or_open_release", post(create_or_open_release_handler))
|
| + |
.route("/add_artifact", post(add_artifact_handler))
|
| + |
.route("/add_location", post(add_location_handler))
|
| + |
.route("/remove_location", post(remove_location_handler))
|
| + |
.route("/attest_artifact", post(attest_artifact_handler))
|
| + |
.route("/redact_artifact", post(redact_artifact_handler))
|
| + |
.route("/get_auto_seed_artifacts", post(get_auto_seed_artifacts_handler))
|
| + |
.route("/set_auto_seed_artifacts", post(set_auto_seed_artifacts_handler))
|
| |
.route("/list_notifications", post(list_notifications_handler))
|
| |
.route("/notification_count", post(notification_count_handler))
|
| |
.route("/clear_notifications", post(clear_notifications_handler))
|
| |
|
| |
Ok::<_, Error>(Json(jobs))
|
| |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct RidBody {
|
| + |
pub rid: identity::RepoId,
|
| + |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct ReleaseByIdBody {
|
| + |
pub rid: identity::RepoId,
|
| + |
pub release_id: String,
|
| + |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct ReleasesByCommitBody {
|
| + |
pub rid: identity::RepoId,
|
| + |
pub sha: git::Oid,
|
| + |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct ComputeCidBody {
|
| + |
pub path: PathBuf,
|
| + |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct CreateOrOpenReleaseBody {
|
| + |
pub rid: identity::RepoId,
|
| + |
pub oid: git::Oid,
|
| + |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct AddArtifactBody {
|
| + |
pub rid: identity::RepoId,
|
| + |
pub release_id: String,
|
| + |
pub cid: String,
|
| + |
pub name: String,
|
| + |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct LocationBody {
|
| + |
pub rid: identity::RepoId,
|
| + |
pub release_id: String,
|
| + |
pub cid: String,
|
| + |
pub url: String,
|
| + |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct AttestBody {
|
| + |
pub rid: identity::RepoId,
|
| + |
pub release_id: String,
|
| + |
pub cid: String,
|
| + |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct RedactBody {
|
| + |
pub rid: identity::RepoId,
|
| + |
pub release_id: String,
|
| + |
pub cid: String,
|
| + |
pub reason: String,
|
| + |
}
|
| + |
|
| + |
#[derive(Serialize, Deserialize)]
|
| + |
struct AutoSeedBody {
|
| + |
pub enabled: bool,
|
| + |
}
|
| + |
|
| + |
async fn list_releases_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(RidBody { rid }): Json<RidBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
Ok::<_, Error>(Json(ctx.list_releases(rid)?))
|
| + |
}
|
| + |
|
| + |
async fn release_by_id_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(ReleaseByIdBody { rid, release_id }): Json<ReleaseByIdBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
Ok::<_, Error>(Json(ctx.release_by_id(rid, release_id)?))
|
| + |
}
|
| + |
|
| + |
async fn releases_by_commit_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(ReleasesByCommitBody { rid, sha }): Json<ReleasesByCommitBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
Ok::<_, Error>(Json(ctx.releases_by_commit(rid, sha)?))
|
| + |
}
|
| + |
|
| + |
async fn compute_artifact_cid_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(ComputeCidBody { path }): Json<ComputeCidBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
Ok::<_, Error>(Json(ctx.compute_cid(path)?))
|
| + |
}
|
| + |
|
| + |
async fn create_or_open_release_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(CreateOrOpenReleaseBody { rid, oid }): Json<CreateOrOpenReleaseBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
Ok::<_, Error>(Json(ctx.create_or_open_release(rid, oid)?))
|
| + |
}
|
| + |
|
| + |
async fn add_artifact_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(AddArtifactBody {
|
| + |
rid,
|
| + |
release_id,
|
| + |
cid,
|
| + |
name,
|
| + |
}): Json<AddArtifactBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
ctx.add_artifact(rid, release_id, cid, name)?;
|
| + |
Ok::<_, Error>(Json(()))
|
| + |
}
|
| + |
|
| + |
async fn add_location_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(LocationBody {
|
| + |
rid,
|
| + |
release_id,
|
| + |
cid,
|
| + |
url,
|
| + |
}): Json<LocationBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
ctx.add_location(rid, release_id, cid, url)?;
|
| + |
Ok::<_, Error>(Json(()))
|
| + |
}
|
| + |
|
| + |
async fn remove_location_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(LocationBody {
|
| + |
rid,
|
| + |
release_id,
|
| + |
cid,
|
| + |
url,
|
| + |
}): Json<LocationBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
ctx.remove_location(rid, release_id, cid, url)?;
|
| + |
Ok::<_, Error>(Json(()))
|
| + |
}
|
| + |
|
| + |
async fn attest_artifact_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(AttestBody {
|
| + |
rid,
|
| + |
release_id,
|
| + |
cid,
|
| + |
}): Json<AttestBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
ctx.attest_artifact(rid, release_id, cid)?;
|
| + |
Ok::<_, Error>(Json(()))
|
| + |
}
|
| + |
|
| + |
async fn redact_artifact_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(RedactBody {
|
| + |
rid,
|
| + |
release_id,
|
| + |
cid,
|
| + |
reason,
|
| + |
}): Json<RedactBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
ctx.redact_artifact(rid, release_id, cid, reason)?;
|
| + |
Ok::<_, Error>(Json(()))
|
| + |
}
|
| + |
|
| + |
async fn get_auto_seed_artifacts_handler(State(ctx): State<Context>) -> impl IntoResponse {
|
| + |
let settings = radicle_types::settings::load(ctx.profile().home().path());
|
| + |
Ok::<_, Error>(Json(settings.auto_seed_artifacts))
|
| + |
}
|
| + |
|
| + |
async fn set_auto_seed_artifacts_handler(
|
| + |
State(ctx): State<Context>,
|
| + |
Json(AutoSeedBody { enabled }): Json<AutoSeedBody>,
|
| + |
) -> impl IntoResponse {
|
| + |
let mut settings = radicle_types::settings::load(ctx.profile().home().path());
|
| + |
settings.auto_seed_artifacts = enabled;
|
| + |
radicle_types::settings::save(ctx.profile().home().path(), &settings)?;
|
| + |
Ok::<_, Error>(Json(()))
|
| + |
}
|