Skip to content

External IPs endpoint returns struct with items Vec #1495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2022
Merged
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
4 changes: 2 additions & 2 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,7 @@ async fn instance_network_interface_update(
async fn instance_external_ip_list(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
path_params: Path<InstancePathParam>,
) -> Result<HttpResponseOk<Vec<views::ExternalIp>>, HttpError> {
) -> Result<HttpResponseOk<ResultsPage<views::ExternalIp>>, HttpError> {
let apictx = rqctx.context();
let nexus = &apictx.nexus;
let path = path_params.into_inner();
Expand All @@ -2517,7 +2517,7 @@ async fn instance_external_ip_list(
instance_name,
)
.await?;
Ok(HttpResponseOk(ips))
Ok(HttpResponseOk(ResultsPage { items: ips, next_page: None }))
};
apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
}
Expand Down
14 changes: 7 additions & 7 deletions nexus/tests/integration_tests/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use omicron_common::api::external::NetworkInterface;
use omicron_nexus::external_api::shared::IpKind;
use omicron_nexus::external_api::shared::IpRange;
use omicron_nexus::external_api::shared::Ipv4Range;
use omicron_nexus::external_api::views::ExternalIp;
use omicron_nexus::external_api::views;
use omicron_nexus::TestInterfaces as _;
use omicron_nexus::{external_api::params, Nexus};
use sled_agent_client::TestInterfaces as _;
Expand All @@ -36,7 +36,7 @@ use std::sync::Arc;
use uuid::Uuid;

use dropshot::test_util::ClientTestContext;
use dropshot::HttpErrorResponseBody;
use dropshot::{HttpErrorResponseBody, ResultsPage};

use nexus_test_utils::identity_eq;
use nexus_test_utils::resource_helpers::{
Expand Down Expand Up @@ -2500,13 +2500,13 @@ async fn test_instance_ephemeral_ip_from_correct_project(
.execute()
.await
.expect("Failed to fetch external IPs")
.parsed_body::<Vec<ExternalIp>>()
.parsed_body::<ResultsPage<views::ExternalIp>>()
.expect("Failed to parse external IPs");
assert_eq!(ips.len(), 1);
assert_eq!(ips[0].kind, IpKind::Ephemeral);
assert_eq!(ips.items.len(), 1);
assert_eq!(ips.items[0].kind, IpKind::Ephemeral);
assert!(
ips[0].ip >= second_range.first_address()
&& ips[0].ip <= second_range.last_address(),
ips.items[0].ip >= second_range.first_address()
&& ips.items[0].ip <= second_range.last_address(),
"Expected the Ephemeral IP to come from the second address \
range, since the first is reserved for a project different from \
the instance's project."
Expand Down
27 changes: 22 additions & 5 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -2972,11 +2972,7 @@
"content": {
"application/json": {
"schema": {
"title": "Array_of_ExternalIp",
"type": "array",
"items": {
"$ref": "#/components/schemas/ExternalIp"
}
"$ref": "#/components/schemas/ExternalIpResultsPage"
}
}
}
Expand Down Expand Up @@ -7261,6 +7257,27 @@
}
]
},
"ExternalIpResultsPage": {
"description": "A single page of results",
"type": "object",
"properties": {
"items": {
"description": "list of items on this page of results",
"type": "array",
"items": {
"$ref": "#/components/schemas/ExternalIp"
}
},
"next_page": {
"nullable": true,
"description": "token used to fetch the next page of results (if any)",
"type": "string"
}
},
"required": [
"items"
]
},
"FieldSchema": {
"description": "The name and type information for a field of a timeseries schema.",
"type": "object",
Expand Down