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
119 changes: 63 additions & 56 deletions nexus/external-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ mod v2025122300;
mod v2026010100;
mod v2026010300;
mod v2026010500;
mod v2026011501;
mod v2026011600;

#[cfg(test)]
Expand Down Expand Up @@ -1618,17 +1617,19 @@ pub trait NexusExternalApi {
method = POST,
path = "/v1/floating-ips",
tags = ["floating-ips"],
versions = VERSION_POOL_SELECTION_ENUMS..VERSION_RENAME_ADDRESS_SELECTOR_TO_ADDRESS_ALLOCATOR,
versions = ..VERSION_IP_VERSION_AND_MULTIPLE_DEFAULT_POOLS,
}]
async fn v2026011501_floating_ip_create(
async fn v2025121200_floating_ip_create(
rqctx: RequestContext<Self::Context>,
query_params: Query<params::ProjectSelector>,
floating_params: TypedBody<v2026011501::FloatingIpCreate>,
floating_params: TypedBody<v2025121200::FloatingIpCreate>,
) -> Result<HttpResponseCreated<views::FloatingIp>, HttpError> {
Self::v2026011600_floating_ip_create(
let floating_params =
floating_params.map(v2026010300::FloatingIpCreate::from);
Self::v2026010300_floating_ip_create(
rqctx,
query_params,
floating_params.map(Into::into),
floating_params,
)
.await
}
Expand All @@ -1648,8 +1649,8 @@ pub trait NexusExternalApi {
floating_params: TypedBody<v2026010300::FloatingIpCreate>,
) -> Result<HttpResponseCreated<views::FloatingIp>, HttpError> {
let floating_params =
floating_params.try_map(v2026011501::FloatingIpCreate::try_from)?;
Self::v2026011501_floating_ip_create(
floating_params.try_map(v2026010500::FloatingIpCreate::try_from)?;
Self::v2026010500_floating_ip_create(
rqctx,
query_params,
floating_params,
Expand All @@ -1663,19 +1664,17 @@ pub trait NexusExternalApi {
method = POST,
path = "/v1/floating-ips",
tags = ["floating-ips"],
versions = ..VERSION_IP_VERSION_AND_MULTIPLE_DEFAULT_POOLS,
versions = VERSION_POOL_SELECTION_ENUMS..VERSION_RENAME_ADDRESS_SELECTOR_TO_ADDRESS_ALLOCATOR,
}]
async fn v2025121200_floating_ip_create(
async fn v2026010500_floating_ip_create(
rqctx: RequestContext<Self::Context>,
query_params: Query<params::ProjectSelector>,
floating_params: TypedBody<v2025121200::FloatingIpCreate>,
floating_params: TypedBody<v2026010500::FloatingIpCreate>,
) -> Result<HttpResponseCreated<views::FloatingIp>, HttpError> {
let floating_params =
floating_params.map(v2026010300::FloatingIpCreate::from);
Self::v2026010300_floating_ip_create(
Self::v2026011600_floating_ip_create(
rqctx,
query_params,
floating_params,
floating_params.map(Into::into),
)
.await
}
Expand Down Expand Up @@ -2188,44 +2187,32 @@ pub trait NexusExternalApi {

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

/// Create instance
#[endpoint {
operation_id = "instance_create",
method = POST,
path = "/v1/instances",
tags = ["instances"],
versions = VERSION_LOCAL_STORAGE..VERSION_IP_VERSION_AND_MULTIPLE_DEFAULT_POOLS,
versions = VERSION_POOL_SELECTION_ENUMS..VERSION_MULTICAST_IMPLICIT_LIFECYCLE_UPDATES,
}]
async fn v2025121200_instance_create(
async fn v2026010500_instance_create(
rqctx: RequestContext<Self::Context>,
query_params: Query<params::ProjectSelector>,
new_instance: TypedBody<v2025121200::InstanceCreate>,
new_instance: TypedBody<v2026010500::InstanceCreate>,
) -> Result<HttpResponseCreated<Instance>, HttpError> {
Self::v2026010100_instance_create(
rqctx,
query_params,
new_instance.map(Into::into),
)
.await
Self::instance_create(rqctx, query_params, new_instance.map(Into::into))
.await
}

/// Create instance
Expand All @@ -2234,16 +2221,19 @@ pub trait NexusExternalApi {
method = POST,
path = "/v1/instances",
tags = ["instances"],
versions =
VERSION_IP_VERSION_AND_MULTIPLE_DEFAULT_POOLS..VERSION_DUAL_STACK_NICS,
versions = VERSION_DUAL_STACK_NICS..VERSION_POOL_SELECTION_ENUMS,
}]
async fn v2026010100_instance_create(
async fn v2026010300_instance_create(
rqctx: RequestContext<Self::Context>,
query_params: Query<params::ProjectSelector>,
new_instance: TypedBody<v2026010100::InstanceCreate>,
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.try_map(TryInto::try_into)?,
)
.await
}

/// Create instance
Expand All @@ -2252,15 +2242,20 @@ pub trait NexusExternalApi {
method = POST,
path = "/v1/instances",
tags = ["instances"],
versions = VERSION_DUAL_STACK_NICS..VERSION_POOL_SELECTION_ENUMS,
versions =
VERSION_IP_VERSION_AND_MULTIPLE_DEFAULT_POOLS..VERSION_DUAL_STACK_NICS,
}]
async fn v2026010300_instance_create(
async fn v2025122300_instance_create(
rqctx: RequestContext<Self::Context>,
query_params: Query<params::ProjectSelector>,
new_instance: TypedBody<v2026010300::InstanceCreate>,
new_instance: TypedBody<v2025122300::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.try_map(TryInto::try_into)?,
)
.await
}

/// Create instance
Expand All @@ -2269,29 +2264,41 @@ pub trait NexusExternalApi {
method = POST,
path = "/v1/instances",
tags = ["instances"],
versions = VERSION_POOL_SELECTION_ENUMS..VERSION_MULTICAST_IMPLICIT_LIFECYCLE_UPDATES,
versions = VERSION_LOCAL_STORAGE..VERSION_IP_VERSION_AND_MULTIPLE_DEFAULT_POOLS,
}]
async fn v2026010500_instance_create(
async fn v2025120300_instance_create(
rqctx: RequestContext<Self::Context>,
query_params: Query<params::ProjectSelector>,
new_instance: TypedBody<v2026010500::InstanceCreate>,
new_instance: TypedBody<v2025120300::InstanceCreate>,
) -> Result<HttpResponseCreated<Instance>, HttpError> {
Self::instance_create(rqctx, query_params, new_instance.map(Into::into))
.await
Self::v2025122300_instance_create(
rqctx,
query_params,
new_instance.map(Into::into),
)
.await
}

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

/// Fetch instance
#[endpoint {
Expand Down
15 changes: 8 additions & 7 deletions nexus/external-api/src/v2025112000.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Nexus external types that changed from 2025112000 to 2025120300
//! Types from API version 2025112000 (INITIAL) that changed in version
//! 2025120300 (LOCAL_STORAGE).

use crate::v2025121200;
use crate::v2025120300;
use crate::v2026010100;
use nexus_types::external_api::params;
use omicron_common::api::external;
Expand Down Expand Up @@ -220,9 +221,9 @@ pub struct InstanceCreate {
/// By default, all instances have outbound connectivity, but no inbound
/// connectivity. These external addresses can be used to provide a fixed,
/// known IP address for making inbound connections to the instance.
// Delegates through v2025121200 → params::ExternalIpCreate
// Delegates through v2025120300 → params::ExternalIpCreate
#[serde(default)]
pub external_ips: Vec<v2025121200::ExternalIpCreate>,
pub external_ips: Vec<v2025120300::ExternalIpCreate>,

/// The multicast groups this instance should join.
///
Expand Down Expand Up @@ -302,9 +303,9 @@ pub struct InstanceCreate {
pub cpu_platform: Option<external::InstanceCpuPlatform>,
}

impl From<InstanceCreate> for v2025121200::InstanceCreate {
fn from(old: InstanceCreate) -> v2025121200::InstanceCreate {
v2025121200::InstanceCreate {
impl From<InstanceCreate> for v2025120300::InstanceCreate {
fn from(old: InstanceCreate) -> v2025120300::InstanceCreate {
v2025120300::InstanceCreate {
identity: old.identity,
ncpus: old.ncpus,
memory: old.memory,
Expand Down
Loading
Loading