Skip to content
Open
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
16 changes: 12 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"agent-api",
"agent-client",
"agent-types",
"agent-types/versions",
"crucible-client-types",
"common",
"control-client",
Expand Down Expand Up @@ -145,6 +146,7 @@ crucible = { path = "./upstairs" }
crucible-agent-api = { path = "./agent-api" }
crucible-agent-client = { path = "./agent-client" }
crucible-agent-types = { path = "./agent-types" }
crucible-agent-types-versions = { path = "./agent-types/versions" }
crucible-client-types = { path = "./crucible-client-types" }
crucible-common = { path = "./common" }
crucible-control-client = { path = "./control-client" }
Expand Down
4 changes: 1 addition & 3 deletions agent-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ license = "MPL-2.0"
edition = "2024"

[dependencies]
crucible-agent-types.workspace = true
crucible-agent-types-versions.workspace = true
crucible-workspace-hack.workspace = true
dropshot.workspace = true
dropshot-api-manager-types.workspace = true
schemars.workspace = true
serde.workspace = true
68 changes: 16 additions & 52 deletions agent-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
// Copyright 2025 Oxide Computer Company
// Copyright 2026 Oxide Computer Company

use std::collections::BTreeMap;

use crucible_agent_types::{
region::{CreateRegion, Region, RegionId},
snapshot::{RunningSnapshot, Snapshot},
};
use crucible_agent_types_versions::latest;
use dropshot::{
HttpError, HttpResponseDeleted, HttpResponseOk, Path, RequestContext,
TypedBody,
};
use dropshot_api_manager_types::api_versions;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

api_versions!([
// WHEN CHANGING THE API (part 1 of 2):
Expand Down Expand Up @@ -51,33 +44,33 @@ pub trait CrucibleAgentApi {
}]
async fn region_list(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<Vec<Region>>, HttpError>;
) -> Result<HttpResponseOk<Vec<latest::region::Region>>, HttpError>;

#[endpoint {
method = POST,
path = "/crucible/0/regions",
}]
async fn region_create(
rqctx: RequestContext<Self::Context>,
body: TypedBody<CreateRegion>,
) -> Result<HttpResponseOk<Region>, HttpError>;
body: TypedBody<latest::region::CreateRegion>,
) -> Result<HttpResponseOk<latest::region::Region>, HttpError>;

#[endpoint {
method = GET,
path = "/crucible/0/regions/{id}",
}]
async fn region_get(
rqctx: RequestContext<Self::Context>,
path: Path<RegionPath>,
) -> Result<HttpResponseOk<Region>, HttpError>;
path: Path<latest::region::RegionPath>,
) -> Result<HttpResponseOk<latest::region::Region>, HttpError>;

#[endpoint {
method = DELETE,
path = "/crucible/0/regions/{id}",
}]
async fn region_delete(
rqctx: RequestContext<Self::Context>,
path: Path<RegionPath>,
path: Path<latest::region::RegionPath>,
) -> Result<HttpResponseDeleted, HttpError>;

#[endpoint {
Expand All @@ -86,25 +79,25 @@ pub trait CrucibleAgentApi {
}]
async fn region_get_snapshots(
rqctx: RequestContext<Self::Context>,
path: Path<RegionPath>,
) -> Result<HttpResponseOk<GetSnapshotResponse>, HttpError>;
path: Path<latest::region::RegionPath>,
) -> Result<HttpResponseOk<latest::snapshot::GetSnapshotResponse>, HttpError>;

#[endpoint {
method = GET,
path = "/crucible/0/regions/{id}/snapshots/{name}",
}]
async fn region_get_snapshot(
rqctx: RequestContext<Self::Context>,
path: Path<GetSnapshotPath>,
) -> Result<HttpResponseOk<Snapshot>, HttpError>;
path: Path<latest::snapshot::GetSnapshotPath>,
) -> Result<HttpResponseOk<latest::snapshot::Snapshot>, HttpError>;

#[endpoint {
method = DELETE,
path = "/crucible/0/regions/{id}/snapshots/{name}",
}]
async fn region_delete_snapshot(
rqctx: RequestContext<Self::Context>,
path: Path<DeleteSnapshotPath>,
path: Path<latest::snapshot::DeleteSnapshotPath>,
) -> Result<HttpResponseDeleted, HttpError>;

#[endpoint {
Expand All @@ -113,44 +106,15 @@ pub trait CrucibleAgentApi {
}]
async fn region_run_snapshot(
rqctx: RequestContext<Self::Context>,
path: Path<RunSnapshotPath>,
) -> Result<HttpResponseOk<RunningSnapshot>, HttpError>;
path: Path<latest::snapshot::RunSnapshotPath>,
) -> Result<HttpResponseOk<latest::snapshot::RunningSnapshot>, HttpError>;

#[endpoint {
method = DELETE,
path = "/crucible/0/regions/{id}/snapshots/{name}/run",
}]
async fn region_delete_running_snapshot(
rc: RequestContext<Self::Context>,
path: Path<RunSnapshotPath>,
path: Path<latest::snapshot::RunSnapshotPath>,
) -> Result<HttpResponseDeleted, HttpError>;
}

#[derive(Deserialize, JsonSchema)]
pub struct RegionPath {
pub id: RegionId,
}

#[derive(Serialize, JsonSchema)]
pub struct GetSnapshotResponse {
pub snapshots: Vec<Snapshot>,
pub running_snapshots: BTreeMap<String, RunningSnapshot>,
}

#[derive(Deserialize, JsonSchema)]
pub struct GetSnapshotPath {
pub id: RegionId,
pub name: String,
}

#[derive(Deserialize, JsonSchema)]
pub struct DeleteSnapshotPath {
pub id: RegionId,
pub name: String,
}

#[derive(Deserialize, JsonSchema)]
pub struct RunSnapshotPath {
pub id: RegionId,
pub name: String,
}
4 changes: 2 additions & 2 deletions agent-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ license = "MPL-2.0"
edition = "2024"

[dependencies]
chrono.workspace = true
crucible-agent-types-versions.workspace = true
crucible-smf.workspace = true
crucible-workspace-hack.workspace = true
serde.workspace = true
schemars.workspace = true
serde.workspace = true

[dev-dependencies]
serde_json.workspace = true
2 changes: 1 addition & 1 deletion agent-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 Oxide Computer Company
// Copyright 2026 Oxide Computer Company

pub mod region;
pub mod smf;
Expand Down
Loading