[pdm-devel] [PATCH datacenter-manager 1/9] server: factor out task filters into `TaskFilters` type
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Jan 20 18:42:53 CET 2025
Am 20.01.25 um 10:29 schrieb Dominik Csapak:
> so we can reuse it
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> lib/pdm-api-types/src/lib.rs | 81 ++++++++++++++++++++++++++++++++++-
> server/src/api/nodes/tasks.rs | 80 ++++++++--------------------------
> 2 files changed, 98 insertions(+), 63 deletions(-)
>
> diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs
> index bf312cc..3844907 100644
> --- a/lib/pdm-api-types/src/lib.rs
> +++ b/lib/pdm-api-types/src/lib.rs
> @@ -219,7 +219,7 @@ pub enum NodePowerCommand {
>
> #[api]
> /// The state of a task.
> -#[derive(Eq, PartialEq, Debug, Serialize, Deserialize)]
> +#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
> #[serde(rename_all = "lowercase")]
> pub enum TaskStateType {
> /// Ok
> @@ -418,3 +418,82 @@ impl fmt::Display for RemoteUpid {
>
> serde_plain::derive_deserialize_from_fromstr!(RemoteUpid, "valid remote upid");
> serde_plain::derive_serialize_from_display!(RemoteUpid);
> +
> +fn limit_default() -> u64 {
> + 50
> +}
> +
> +#[api(
> + properties: {
> + start: {
> + type: u64,
> + description: "List tasks beginning from this offset.",
> + default: 0,
> + optional: true,
> + },
> + limit: {
> + type: u64,
> + description: "Only list this amount of tasks. (0 means no limit)",
> + default: 50,
> + optional: true,
> + },
> + running: {
> + type: bool,
> + description: "Only list running tasks.",
> + optional: true,
> + default: false,
> + },
> + errors: {
> + type: bool,
> + description: "Only list erroneous tasks.",
> + optional:true,
> + default: false,
> + },
> + userfilter: {
> + optional: true,
> + type: String,
> + description: "Only list tasks from this user.",
> + },
> + since: {
> + type: i64,
> + description: "Only list tasks since this UNIX epoch.",
> + optional: true,
> + },
> + until: {
> + type: i64,
> + description: "Only list tasks until this UNIX epoch.",
> + optional: true,
> + },
> + typefilter: {
> + optional: true,
> + type: String,
> + description: "Only list tasks whose type contains this.",
> + },
> + statusfilter: {
General thought:
Before relying on these spellings even more we might take the chance and clean that up,
i.e. here already now directly and in our other projects support both until next
major release. I.e., separate words and not glue them together or just drop "filter",
it's used inconsistently anyway.
Might be little, but doubling down on ugly things even if they are small is not really
great either. Maybe we can go through the whole API schema for the next major release
and do a bigger clean-up before the pain of doing that increases significantly.
More information about the pdm-devel
mailing list