cloudstack-cloudmonkey icon indicating copy to clipboard operation
cloudstack-cloudmonkey copied to clipboard

Implement better filtering for autocompletion

Open onitake opened this issue 5 years ago • 2 comments

When sending actions against a resource, there is no way to filter the autocompletion results, except via fields that the API accepts.

For example, the start virtualmachine API only accepts the VM UUID, which is a global value and almost useless for autocompletion if there are a lot of VMs for the current account.

Please implement a better way to select resources, for example by adding name, project or other arguments that would query the respective APIs for a list of resources first.

onitake avatar Mar 12 '19 10:03 onitake

This will probably need special cases for each API call or group of API calls. Alternatively, it may be possible to attach a special-case filter to arguments (such as name) instead. This would then automatically apply to all API calls that have this parameter.

Additional care must be taken to "inject" the other parameters given by the user into the query call.

Usage scenaria with special handling for project and name:

  1. User enters start virtualmachine project=abc<TAB>
  2. cmk jumps into the special handler for the project parameter and issues a list projects API call
  3. cmk filters the results by the user-specified prefix "abc" and returns the list to the user
  4. User selects a project from the list, then enters name=xy<TAB>
  5. cmk jumps into the special handler for name and issues a list virtualmachines call, passing along the other parameters (project in this case)
  6. cmk filters the results by the "xy" prefix and presents the list of VMs to the user
  7. User selects the VM from the list and presses enter to send the start command

To make this work, it may be necessary to implement a sort of "translation" between the special parameters and the actual parameters sent later with the API call. For example, when autocompletion for one parameter terminates, the parameter could be automagically transformed into the actual parameter. For project this would mean that after the user selects the project from the list, the parameter is replaced with projectid=<UUID>.

onitake avatar Jun 09 '20 08:06 onitake

@onitake you probably want to do filtering by manually calling APIs/response to find what you need or use the UI for adv. search capabilities which will probably require a lot of rewriting of cmk code; (to show a widget on CLI with probably a ncurses UI that takes in these filtering parameter while autocompletion).

rohityadavcloud avatar Jun 18 '20 06:06 rohityadavcloud