Skip to content

Commit

Permalink
defined 'range_min', 'range_max' to specify range for UI slider, also…
Browse files Browse the repository at this point in the history
… added optional 'null_value' to set an extreme value that should be sent as 'null/None' to the API
  • Loading branch information
Palabola committed Sep 26, 2024
1 parent 5660383 commit da2c6b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/sc_keeper/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def search_servers(
response: Response,
partial_name_or_id: options.partial_name_or_id = None,
vcpus_min: options.vcpus_min = 1,
vcpus_max: options.vcpus_max = 256,
vcpus_max: options.vcpus_max = None,
architecture: options.architecture = None,
cpu_manufacturer: options.cpu_manufacturer = None,
cpu_family: options.cpu_family = None,
Expand Down Expand Up @@ -282,7 +282,7 @@ def search_servers(

if vcpus_min:
conditions.add(Server.vcpus >= vcpus_min)
if vcpus_max and vcpus_max < 256:
if vcpus_max:
conditions.add(Server.vcpus <= vcpus_max)
if architecture:
conditions.add(Server.cpu_architecture.in_(architecture))
Expand Down
9 changes: 7 additions & 2 deletions src/sc_keeper/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,25 @@
json_schema_extra={
"category_id": FilterCategories.PROCESSOR,
"unit": "vCPUs",
"range_min": 1,
"range_max": 256
},
),
]

vcpus_max = Annotated[
int,
Optional[int],
Query(
title="Maximum vCPUs",
description="Maximum number of virtual CPUs.",
ge=1,
le=256,
json_schema_extra={
"category_id": FilterCategories.PROCESSOR,
"unit": "vCPUs"
"unit": "vCPUs",
"range_min": 1,
"range_max": 256,
"null_value": 256
},
),
]
Expand Down

0 comments on commit da2c6b0

Please sign in to comment.