Skip to content
Draft
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions nexus/external-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ license = "MPL-2.0"
[lints]
workspace = true

[dev-dependencies]
proptest.workspace = true
test-strategy.workspace = true

[dependencies]
anyhow.workspace = true
base64.workspace = true
Expand Down
62 changes: 54 additions & 8 deletions nexus/external-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ mod v2025122300;
mod v2026010100;
mod v2026010300;
mod v2026010500;
mod v2026011300;

api_versions!([
// API versions are in the format YYYYMMDDNN.0.0, defined below as
Expand Down Expand Up @@ -2180,7 +2181,8 @@ pub trait NexusExternalApi {
new_instance: TypedBody<v2026010100::InstanceCreate>,
) -> Result<HttpResponseCreated<Instance>, HttpError> {
let new_instance = new_instance.try_map(TryInto::try_into)?;
Self::instance_create(rqctx, query_params, new_instance).await
Self::v2026010300_instance_create(rqctx, query_params, new_instance)
.await
}

/// Create instance
Expand All @@ -2197,7 +2199,8 @@ pub trait NexusExternalApi {
new_instance: TypedBody<v2026010300::InstanceCreate>,
) -> Result<HttpResponseCreated<Instance>, HttpError> {
let new_instance = new_instance.try_map(TryInto::try_into)?;
Self::instance_create(rqctx, query_params, new_instance).await
Self::v2026010500_instance_create(rqctx, query_params, new_instance)
.await
}

/// Create instance
Expand All @@ -2213,16 +2216,34 @@ pub trait NexusExternalApi {
query_params: Query<params::ProjectSelector>,
new_instance: TypedBody<v2026010500::InstanceCreate>,
) -> Result<HttpResponseCreated<Instance>, HttpError> {
Self::instance_create(rqctx, query_params, new_instance.map(Into::into))
let new_instance = new_instance.map(Into::into);
Self::v2026011300_instance_create(rqctx, query_params, new_instance)
.await
}

/// Create instance
#[endpoint {
operation_id = "instance_create",
method = POST,
path = "/v1/instances",
tags = ["instances"],
versions = VERSION_MULTICAST_IMPLICIT_LIFECYCLE_UPDATES..,
versions = VERSION_MULTICAST_IMPLICIT_LIFECYCLE_UPDATES..VERSION_VPC_SUBNET_ATTACHMENT,
}]
async fn v2026011300_instance_create(
rqctx: RequestContext<Self::Context>,
query_params: Query<params::ProjectSelector>,
new_instance: TypedBody<v2026011300::InstanceCreate>,
) -> Result<HttpResponseCreated<Instance>, HttpError> {
let new_instance = new_instance.map(Into::into);
Self::instance_create(rqctx, query_params, new_instance).await
}

/// Create instance
#[endpoint {
method = POST,
path = "/v1/instances",
tags = ["instances"],
versions = VERSION_VPC_SUBNET_ATTACHMENT..,
}]
async fn instance_create(
rqctx: RequestContext<Self::Context>,
Expand Down Expand Up @@ -3432,21 +3453,46 @@ pub trait NexusExternalApi {
HttpError,
> {
let interface_params = interface_params.try_map(TryInto::try_into)?;
let HttpResponseCreated(nic) = Self::instance_network_interface_create(
let HttpResponseCreated(nic) =
Self::v2026011300_instance_network_interface_create(
rqctx,
query_params,
interface_params,
)
.await?;
nic.try_into().map(HttpResponseCreated).map_err(HttpError::from)
}

/// Create network interface
#[endpoint {
operation_id = "instance_network_interface_create",
method = POST,
path = "/v1/network-interfaces",
tags = ["instances"],
versions = VERSION_DUAL_STACK_NICS..VERSION_VPC_SUBNET_ATTACHMENT,
}]
async fn v2026011300_instance_network_interface_create(
rqctx: RequestContext<Self::Context>,
query_params: Query<params::InstanceSelector>,
interface_params: TypedBody<
v2026011300::InstanceNetworkInterfaceCreate,
>,
) -> Result<HttpResponseCreated<InstanceNetworkInterface>, HttpError> {
let interface_params = interface_params.map(Into::into);
Self::instance_network_interface_create(
rqctx,
query_params,
interface_params,
)
.await?;
nic.try_into().map(HttpResponseCreated).map_err(HttpError::from)
.await
}

/// Create network interface
#[endpoint {
method = POST,
path = "/v1/network-interfaces",
tags = ["instances"],
versions = VERSION_DUAL_STACK_NICS..,
versions = VERSION_VPC_SUBNET_ATTACHMENT..,
}]
async fn instance_network_interface_create(
rqctx: RequestContext<Self::Context>,
Expand Down
Loading
Loading