Files
codegenerator/codegenerator/templates/rust_cli/query_parameters.j2
Artem Goncharov ca752ffa71 Improve UX clarity of "limit" query parameter
Rename "limit" query parameter of the list operations to "page-size" for
giving precise meaning (keep alias "limit"). This is necessary to
finally resolve the conflict that we have in the python-openstackclient
where "limit" means a page size and all entries are fetched unless you
also specify the marker (which is not something anybody can really
understand why).

Change-Id: I9a6ddcbe30d92c4d190229ac77a10c28eb0015fb
Signed-off-by: Artem Goncharov <artem.goncharov@gmail.com>
2025-06-26 16:17:49 +02:00

50 lines
1.9 KiB
Django/Jinja

/// Query parameters
#[derive(Args)]
struct QueryParameters {
{%- for name, param in type_manager.parameters | dictsort %}
{%- if param.location == "query" %}
{%- if not param.resource_link %}
{{ macros.docstring(param.description_with_defaults(), indent=4) }}
{{ param.clap_macros }}
{{ param.local_name}}: {{ param.type_hint }},
{%- else %}
{% set res_name = param.resource_link.split(".")[0].split('/')[-1] %}
/// {{ res_name | title }} resource for which the operation should be performed.
#[command(flatten)]
{{ res_name }}: {{ res_name | title }}Input,
{%- endif %}
{%- endif %}
{%- endfor %}
}
{%- for (k, param) in type_manager.get_parameters("query") %}
{%- if param.resource_link %}
{% set res_name = param.resource_link.split(".")[0].split('/')[-1] %}
/// {{ res_name | title }} input select group
#[derive(Args)]
#[group(required = {{ 'true' if param.is_required else 'false' }}, multiple = false)]
struct {{ res_name | title }}Input {
/// {{ res_name | title }} Name.
#[arg(long, help_heading = "Path parameters", value_name = "{{ res_name | upper }}_NAME")]
{{ res_name }}_name: Option<String>,
/// {{ res_name | title }} ID.
#[arg(long, help_heading = "Path parameters", value_name = "{{ res_name | upper }}_ID")]
{{ res_name }}_id: Option<String>,
{%- if res_name == "user" %}
/// Current authenticated user.
#[arg(long, help_heading = "Path parameters", action = clap::ArgAction::SetTrue)]
current_user: bool,
{%- elif res_name == "project" %}
/// Current project.
#[arg(long, help_heading = "Path parameters", action = clap::ArgAction::SetTrue)]
current_project: bool,
{%- elif res_name == "domain" %}
/// Current domain.
#[arg(long, help_heading = "Path parameters", action = clap::ArgAction::SetTrue)]
current_domain: bool,
{%- endif %}
}
{%- endif %}
{%- endfor %}