diff --git a/openstack_cli/src/identity/v4/federation/identity_provider/list.rs b/openstack_cli/src/identity/v4/federation/identity_provider/list.rs index e1d052dec..51bda3304 100644 --- a/openstack_cli/src/identity/v4/federation/identity_provider/list.rs +++ b/openstack_cli/src/identity/v4/federation/identity_provider/list.rs @@ -30,6 +30,7 @@ use crate::output::OutputProcessor; use openstack_sdk::api::QueryAsync; use openstack_sdk::api::identity::v4::federation::identity_provider::list; +use openstack_sdk::api::{Pagination, paged}; use openstack_types::identity::v4::federation::identity_provider::response::list::IdentityProviderResponse; /// List identity providers. Without any filters only global identity providers @@ -48,6 +49,10 @@ pub struct IdentityProvidersCommand { /// Path parameters #[command(flatten)] path: PathParameters, + + /// Total limit of entities count to return. Use this when there are too many entries. + #[arg(long, default_value_t = 10000)] + max_items: usize, } /// Query parameters @@ -57,6 +62,18 @@ struct QueryParameters { #[arg(help_heading = "Query parameters", long)] domain_id: Option, + /// Limit number of entries on the single response page. + #[arg( + help_heading = "Query parameters", + long("page-size"), + visible_alias("limit") + )] + limit: Option, + + /// Page marker (id of the last entry on the previous page. + #[arg(help_heading = "Query parameters", long)] + marker: Option, + /// Filters the response by IDP name. #[arg(help_heading = "Query parameters", long)] name: Option, @@ -91,12 +108,20 @@ impl IdentityProvidersCommand { if let Some(val) = &self.query.domain_id { ep_builder.domain_id(val); } + if let Some(val) = &self.query.limit { + ep_builder.limit(*val); + } + if let Some(val) = &self.query.marker { + ep_builder.marker(val); + } let ep = ep_builder .build() .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; - let data: Vec = ep.query_async(client).await?; + let data: Vec = paged(ep, Pagination::Limit(self.max_items)) + .query_async(client) + .await?; op.output_list::(data)?; // Show command specific hints op.show_command_hint()?; diff --git a/openstack_sdk/src/api/identity/v4/federation/identity_provider/list.rs b/openstack_sdk/src/api/identity/v4/federation/identity_provider/list.rs index 52d78fda1..f35654a5f 100644 --- a/openstack_sdk/src/api/identity/v4/federation/identity_provider/list.rs +++ b/openstack_sdk/src/api/identity/v4/federation/identity_provider/list.rs @@ -29,6 +29,7 @@ use crate::api::rest_endpoint_prelude::*; use std::borrow::Cow; +use crate::api::Pageable; #[derive(Builder, Debug, Clone)] #[builder(setter(strip_option))] pub struct Request<'a> { @@ -36,6 +37,14 @@ pub struct Request<'a> { #[builder(default, setter(into))] domain_id: Option>, + /// Limit number of entries on the single response page. + #[builder(default)] + limit: Option, + + /// Page marker (id of the last entry on the previous page. + #[builder(default, setter(into))] + marker: Option>, + /// Filters the response by IDP name. #[builder(default, setter(into))] name: Option>, @@ -91,6 +100,8 @@ impl RestEndpoint for Request<'_> { let mut params = QueryParams::default(); params.push_opt("name", self.name.as_ref()); params.push_opt("domain_id", self.domain_id.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("marker", self.marker.as_ref()); params } @@ -113,6 +124,7 @@ impl RestEndpoint for Request<'_> { Some(ApiVersion::new(4, 0)) } } +impl Pageable for Request<'_> {} #[cfg(test)] mod tests {