Skip to content

Commit 9c8c34e

Browse files
committed
external IPs endpoint returns ResultsPage instead of Vec
1 parent 5e835f1 commit 9c8c34e

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

nexus/src/external_api/http_entrypoints.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,7 @@ async fn instance_network_interface_update(
25002500
async fn instance_external_ip_list(
25012501
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
25022502
path_params: Path<InstancePathParam>,
2503-
) -> Result<HttpResponseOk<Vec<views::ExternalIp>>, HttpError> {
2503+
) -> Result<HttpResponseOk<ResultsPage<views::ExternalIp>>, HttpError> {
25042504
let apictx = rqctx.context();
25052505
let nexus = &apictx.nexus;
25062506
let path = path_params.into_inner();
@@ -2517,7 +2517,7 @@ async fn instance_external_ip_list(
25172517
instance_name,
25182518
)
25192519
.await?;
2520-
Ok(HttpResponseOk(ips))
2520+
Ok(HttpResponseOk(ResultsPage { items: ips, next_page: None }))
25212521
};
25222522
apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
25232523
}

nexus/tests/integration_tests/instances.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use omicron_common::api::external::NetworkInterface;
2727
use omicron_nexus::external_api::shared::IpKind;
2828
use omicron_nexus::external_api::shared::IpRange;
2929
use omicron_nexus::external_api::shared::Ipv4Range;
30-
use omicron_nexus::external_api::views::ExternalIp;
30+
use omicron_nexus::external_api::views;
3131
use omicron_nexus::TestInterfaces as _;
3232
use omicron_nexus::{external_api::params, Nexus};
3333
use sled_agent_client::TestInterfaces as _;
@@ -36,7 +36,7 @@ use std::sync::Arc;
3636
use uuid::Uuid;
3737

3838
use dropshot::test_util::ClientTestContext;
39-
use dropshot::HttpErrorResponseBody;
39+
use dropshot::{HttpErrorResponseBody, ResultsPage};
4040

4141
use nexus_test_utils::identity_eq;
4242
use nexus_test_utils::resource_helpers::{
@@ -2500,13 +2500,13 @@ async fn test_instance_ephemeral_ip_from_correct_project(
25002500
.execute()
25012501
.await
25022502
.expect("Failed to fetch external IPs")
2503-
.parsed_body::<Vec<ExternalIp>>()
2503+
.parsed_body::<ResultsPage<views::ExternalIp>>()
25042504
.expect("Failed to parse external IPs");
2505-
assert_eq!(ips.len(), 1);
2506-
assert_eq!(ips[0].kind, IpKind::Ephemeral);
2505+
assert_eq!(ips.items.len(), 1);
2506+
assert_eq!(ips.items[0].kind, IpKind::Ephemeral);
25072507
assert!(
2508-
ips[0].ip >= second_range.first_address()
2509-
&& ips[0].ip <= second_range.last_address(),
2508+
ips.items[0].ip >= second_range.first_address()
2509+
&& ips.items[0].ip <= second_range.last_address(),
25102510
"Expected the Ephemeral IP to come from the second address \
25112511
range, since the first is reserved for a project different from \
25122512
the instance's project."

openapi/nexus.json

+22-5
Original file line numberDiff line numberDiff line change
@@ -2972,11 +2972,7 @@
29722972
"content": {
29732973
"application/json": {
29742974
"schema": {
2975-
"title": "Array_of_ExternalIp",
2976-
"type": "array",
2977-
"items": {
2978-
"$ref": "#/components/schemas/ExternalIp"
2979-
}
2975+
"$ref": "#/components/schemas/ExternalIpResultsPage"
29802976
}
29812977
}
29822978
}
@@ -7261,6 +7257,27 @@
72617257
}
72627258
]
72637259
},
7260+
"ExternalIpResultsPage": {
7261+
"description": "A single page of results",
7262+
"type": "object",
7263+
"properties": {
7264+
"items": {
7265+
"description": "list of items on this page of results",
7266+
"type": "array",
7267+
"items": {
7268+
"$ref": "#/components/schemas/ExternalIp"
7269+
}
7270+
},
7271+
"next_page": {
7272+
"nullable": true,
7273+
"description": "token used to fetch the next page of results (if any)",
7274+
"type": "string"
7275+
}
7276+
},
7277+
"required": [
7278+
"items"
7279+
]
7280+
},
72647281
"FieldSchema": {
72657282
"description": "The name and type information for a field of a timeseries schema.",
72667283
"type": "object",

0 commit comments

Comments
 (0)