Skip to content

Commit 5e6f218

Browse files
committed
on second thought, use one-off struct so it can have its own description
1 parent 7551fd3 commit 5e6f218

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

nexus/src/external_api/http_entrypoints.rs

Lines changed: 2 additions & 2 deletions
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::Results<views::ExternalIp>>, HttpError> {
2503+
) -> Result<HttpResponseOk<views::ExternalIps>, 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.into()))
2520+
Ok(HttpResponseOk(views::ExternalIps { items: ips }))
25212521
};
25222522
apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
25232523
}

nexus/src/external_api/views.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ use std::net::IpAddr;
2020
use std::net::SocketAddrV6;
2121
use uuid::Uuid;
2222

23-
/// Wrapper analogous to [`dropshot::ResultsPage`] for unpaginated list endpoints
24-
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
25-
#[serde(rename_all = "snake_case")]
26-
#[schemars(rename = "{}Results")]
27-
pub struct Results<T> {
28-
pub items: Vec<T>,
29-
}
30-
31-
impl<T> From<Vec<T>> for Results<T> {
32-
fn from(items: Vec<T>) -> Self {
33-
Self { items }
34-
}
35-
}
36-
3723
// IDENTITY METADATA
3824

3925
/// Identity-related metadata that's included in "asset" public API objects
@@ -407,6 +393,13 @@ pub struct ExternalIp {
407393
pub kind: IpKind,
408394
}
409395

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+
410403
// RACKS
411404

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

nexus/tests/integration_tests/instances.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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::Results<views::ExternalIp>>()
2503+
.parsed_body::<views::ExternalIps>()
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,7 +2972,7 @@
29722972
"content": {
29732973
"application/json": {
29742974
"schema": {
2975-
"$ref": "#/components/schemas/ExternalIpResults"
2975+
"$ref": "#/components/schemas/ExternalIps"
29762976
}
29772977
}
29782978
}
@@ -7257,8 +7257,8 @@
72577257
}
72587258
]
72597259
},
7260-
"ExternalIpResults": {
7261-
"description": "Wrapper analogous to [`dropshot::ResultsPage`] for unpaginated list endpoints",
7260+
"ExternalIps": {
7261+
"description": "Unpaginated list of [`ExternalIp`]",
72627262
"type": "object",
72637263
"properties": {
72647264
"items": {

0 commit comments

Comments
 (0)