Skip to content

Commit b9f6c1d

Browse files
committed
ok fine, use ResultsPage
1 parent 5e6f218 commit b9f6c1d

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-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<views::ExternalIps>, 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(views::ExternalIps { items: ips }))
2520+
Ok(HttpResponseOk(ResultsPage { items: ips, next_page: None }))
25212521
};
25222522
apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
25232523
}

nexus/src/external_api/views.rs

-7
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,6 @@ pub struct ExternalIp {
393393
pub kind: IpKind,
394394
}
395395

396-
/// Unpaginated list of [`ExternalIp`]
397-
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
398-
#[serde(rename_all = "snake_case")]
399-
pub struct ExternalIps {
400-
pub items: Vec<ExternalIp>,
401-
}
402-
403396
// RACKS
404397

405398
/// Client view of an [`Rack`]

nexus/tests/integration_tests/instances.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -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,7 +2500,7 @@ async fn test_instance_ephemeral_ip_from_correct_project(
25002500
.execute()
25012501
.await
25022502
.expect("Failed to fetch external IPs")
2503-
.parsed_body::<views::ExternalIps>()
2503+
.parsed_body::<ResultsPage<views::ExternalIp>>()
25042504
.expect("Failed to parse external IPs");
25052505
assert_eq!(ips.items.len(), 1);
25062506
assert_eq!(ips.items[0].kind, IpKind::Ephemeral);

openapi/nexus.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -2972,7 +2972,7 @@
29722972
"content": {
29732973
"application/json": {
29742974
"schema": {
2975-
"$ref": "#/components/schemas/ExternalIps"
2975+
"$ref": "#/components/schemas/ExternalIpResultsPage"
29762976
}
29772977
}
29782978
}
@@ -7257,15 +7257,21 @@
72577257
}
72587258
]
72597259
},
7260-
"ExternalIps": {
7261-
"description": "Unpaginated list of [`ExternalIp`]",
7260+
"ExternalIpResultsPage": {
7261+
"description": "A single page of results",
72627262
"type": "object",
72637263
"properties": {
72647264
"items": {
7265+
"description": "list of items on this page of results",
72657266
"type": "array",
72667267
"items": {
72677268
"$ref": "#/components/schemas/ExternalIp"
72687269
}
7270+
},
7271+
"next_page": {
7272+
"nullable": true,
7273+
"description": "token used to fetch the next page of results (if any)",
7274+
"type": "string"
72697275
}
72707276
},
72717277
"required": [

0 commit comments

Comments
 (0)