Skip to content

Use Related metadata for autocomplete API discovery - #214

Merged
borisstoyanov merged 3 commits into
apache:mainfrom
dheeraj12347:feature/related-autocomplete
Sep 9, 2026
Merged

Use Related metadata for autocomplete API discovery#214
borisstoyanov merged 3 commits into
apache:mainfrom
dheeraj12347:feature/related-autocomplete

Conversation

@dheeraj12347

@dheeraj12347 dheeraj12347 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes apache/cloudstack#10442

CloudMonkey already parses and stores the Related metadata exposed by CloudStack APIs in APIArg.Related, but findAutocompleteAPI() did not use this information during autocomplete API discovery.

This change updates autocomplete API selection to prefer authoritative Related metadata before falling back to the existing heuristic-based lookup logic. This improves reliability for entity-reference parameter completion while preserving backward compatibility with the current behavior.

Changes

  • Use APIArg.Related when selecting the autocomplete lookup API.
  • Prefer Related APIs whose noun matches the expected resource noun.
  • Fall back to any valid Related list* API if no noun match is found.
  • Preserve all existing heuristic-based lookup logic as a fallback.
  • Add unit test coverage for Related-based autocomplete API discovery.

Validation

Verified runtime behavior for common entity-reference parameters:

  • zoneidlistZones
  • domainidlistDomains
  • networkidlistNetworks

Added unit tests covering:

  • Related noun match selection.
  • Related API fallback selection.
  • Empty Related metadata fallback to existing heuristics.
  • Non-list Related metadata fallback to existing heuristics.
  • Map-type argument handling.

Build and validation:

go fmt ./...
go test ./...
go build -o bin/cmk .

Test results:

ok github.com/apache/cloudstack-cloudmonkey/cli

@DaanHoogland
DaanHoogland marked this pull request as draft June 9, 2026 06:55
@DaanHoogland
DaanHoogland requested review from Pearl1594 and soreana June 9, 2026 06:55
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

✅ Build complete for PR #214.

📦 Binary artifacts are available in the workflow run (expires on September 19, 2026).

Note: Download artifacts by clicking on the workflow run link above, then scroll to the "Artifacts" section.
Artifacts from PR builds are for testing only and may contain unreviewed, malicious code.

@dheeraj12347
dheeraj12347 marked this pull request as ready for review June 19, 2026 08:47
@dheeraj12347

Copy link
Copy Markdown
Contributor Author

Hi @Pearl1594 and @soreana,

I've updated PR #214 based on my planned Phase 1 deliverable. The implementation now uses APIArg.Related metadata for autocomplete API discovery, with fallback to the existing heuristic-based logic to preserve current behavior.

Since opening the PR, I've also added unit tests covering:

  • Related noun match selection
  • Related API fallback selection
  • Empty Related metadata fallback
  • Non-list Related metadata fallback
  • Map-type argument handling

The PR has been marked ready for review. Whenever you have time, I would appreciate your feedback on the approach and implementation.

Thank you!

@borisstoyanov

Copy link
Copy Markdown
Contributor

@dheeraj12347 thanks for this feature, can you share your testing please. I'm including it in the milestone

@borisstoyanov borisstoyanov added this to the 6.6.0 milestone Aug 6, 2026
@dheeraj12347

Copy link
Copy Markdown
Contributor Author

@dheeraj12347 thanks for this feature, can you share your testing please. I'm including it in the milestone

Hi @borisstoyanov , thanks!

For PR #214, I previously validated the changes with:

  • go fmt ./...
  • go test ./...
  • go build -o bin/cmk .

The relevant package tests passed (github.com/apache/cloudstack-cloudmonkey/cli).

I also manually verified autocomplete for common entity-reference parameters:

  • zoneidlistZones
  • domainidlistDomains
  • networkidlistNetworks

The added unit tests cover Related noun matching, Related API fallback, empty/non-list Related metadata fallback, and map-type arguments.

dheeraj12347 and others added 3 commits September 9, 2026 09:47
Checking Related before the heuristics changed 47 existing completions
against the bundled API cache, many of them wrong: registerIso projectid
resolved to listProjectAccounts instead of listProjects, acquirePodIpAddress
podid to listZones instead of listPods, and executeWebhookDelivery webhookid
to listWebhookDeliveries instead of listWebhooks. The loose Related match
picks the first list API in the array, whatever its noun.

Move the Related lookup after the noun heuristics and run it only when they
found no API. That keeps all 142 new completions Related metadata adds and
leaves every existing completion untouched. Add a test pinning the ordering.
@borisstoyanov
borisstoyanov force-pushed the feature/related-autocomplete branch from 1b33bad to 622e83b Compare September 9, 2026 06:51
@borisstoyanov
borisstoyanov merged commit 9a04d5b into apache:main Sep 9, 2026
4 of 5 checks passed
borisstoyanov added a commit that referenced this pull request Sep 10, 2026
The file landed without a header in #214, so the Apache RAT check has
been failing on main since 9a04d5b.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GSoC: Improve CloudMonkey user experience by enhancing autocompletion

2 participants