Skip to content

Commit 67bdc40

Browse files
committed
Add pagination for adoption requests
1 parent c2a64c1 commit 67bdc40

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

nexus/external-api/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6684,7 +6684,7 @@ pub trait NexusExternalApi {
66846684
}]
66856685
async fn physical_disk_list_adoption_requests(
66866686
rqctx: RequestContext<Self::Context>,
6687-
query: Query<PaginationParams<EmptyScanParams, String>>,
6687+
query_params: Query<PaginatedById>,
66886688
) -> Result<
66896689
HttpResponseOk<
66906690
ResultsPage<latest::physical_disk::PhysicalDiskAdoptionRequest>,

nexus/src/external_api/http_entrypoints.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6740,36 +6740,31 @@ impl NexusExternalApi for NexusExternalApiImpl {
67406740

67416741
async fn physical_disk_list_adoption_requests(
67426742
rqctx: RequestContext<Self::Context>,
6743-
query: Query<PaginationParams<EmptyScanParams, String>>,
6743+
query_params: Query<PaginatedById>,
67446744
) -> Result<
67456745
HttpResponseOk<ResultsPage<PhysicalDiskAdoptionRequest>>,
67466746
HttpError,
67476747
> {
67486748
let apictx = rqctx.context();
6749-
let pag_params = query.into_inner();
6750-
if let dropshot::WhichPage::Next(last_seen) = &pag_params.page {
6751-
return Err(Error::invalid_value(
6752-
last_seen.clone(),
6753-
"bad page token",
6754-
)
6755-
.into());
6756-
}
67576749
let handler = async {
67586750
let nexus = &apictx.context.nexus;
6751+
let query = query_params.into_inner();
67596752
let opctx =
67606753
crate::context::op_context_for_external_api(&rqctx).await?;
6761-
let pagparams = DataPageParams {
6762-
marker: None,
6763-
direction: dropshot::PaginationOrder::Ascending,
6764-
limit: std::num::NonZeroU32::new(100).unwrap(),
6765-
};
67666754
let requests = nexus
6767-
.physical_disk_adoption_request_list(&opctx, &pagparams)
6755+
.physical_disk_adoption_request_list(
6756+
&opctx,
6757+
&data_page_params_for(&rqctx, &query)?,
6758+
)
67686759
.await?
67696760
.into_iter()
67706761
.map(|r| r.into())
67716762
.collect();
6772-
Ok(HttpResponseOk(ResultsPage { items: requests, next_page: None }))
6763+
Ok(HttpResponseOk(ScanById::results_page(
6764+
&query,
6765+
requests,
6766+
&|_, req: &PhysicalDiskAdoptionRequest| req.id,
6767+
)?))
67736768
};
67746769
apictx
67756770
.context

openapi/nexus/nexus-2026040200.0.0-57a417.json renamed to openapi/nexus/nexus-2026040200.0.0-57f2d4.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7722,6 +7722,13 @@
77227722
"nullable": true,
77237723
"type": "string"
77247724
}
7725+
},
7726+
{
7727+
"in": "query",
7728+
"name": "sort_by",
7729+
"schema": {
7730+
"$ref": "#/components/schemas/IdSortMode"
7731+
}
77257732
}
77267733
],
77277734
"responses": {

openapi/nexus/nexus-latest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nexus-2026040200.0.0-57a417.json
1+
nexus-2026040200.0.0-57f2d4.json

0 commit comments

Comments
 (0)