Skip to content

Use Related metadata for autocomplete API discovery#214

Open
dheeraj12347 wants to merge 2 commits into
apache:mainfrom
dheeraj12347:feature/related-autocomplete
Open

Use Related metadata for autocomplete API discovery#214
dheeraj12347 wants to merge 2 commits into
apache:mainfrom
dheeraj12347:feature/related-autocomplete

Conversation

@dheeraj12347

@dheeraj12347 dheeraj12347 commented Jun 8, 2026

Copy link
Copy Markdown

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 June 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
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!

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

1 participant