Bug 1352044

Summary: [RFE] Add support for Bulk queries
Product: Red Hat CloudForms Management Engine Reporter: abellott
Component: APIAssignee: abellott
Status: CLOSED CURRENTRELEASE QA Contact: Martin Kourim <mkourim>
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: cpelland, jhardy, obarenbo, psavage, simaishi
Target Milestone: GAKeywords: FutureFeature, TestOnly
Target Release: 5.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.8.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1391718 (view as bug list) Environment:
Last Closed: 2017-06-12 16:58:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1391718    

Description abellott 2016-07-01 13:28:45 UTC
While the current interfaces support bulk actions on operate/control operations on resources, there is a need to support bulk queries.  

Seperate than a filtered search, this is the case where customers have a list of resource identifiers, (id, guid, name, etc) that need to be queried for additional details/attributes.

Implementing this by a GET parameter will be limited by character size (i.e. by_guid=guid1,guid2,...) 

We need to support a new action "query" for all collections.  This can be implemented in a generic way, but supporting different identifiers based on the collection, i.e. id, href for all, but guid for vms, hosts, etc. description for groups, etc.

Role identifier for the new action would be the same as the resource :read action in api.yml (for Rbac purposes).

Example usage would be:


POST /api/vms?attributes=power_state,tools_status,....

{
   "action" : "query",
   "resources" : [
      { "guid" : "...." },
      { "guid" : "...." },
      ...
   ]
}

Comment 3 CFME Bot 2016-09-23 13:26:28 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/3df001c49095a7fe70f01abbedba563b7a448f11

commit 3df001c49095a7fe70f01abbedba563b7a448f11
Author:     Alberto Bellotti <abellott>
AuthorDate: Mon Sep 19 13:35:00 2016 -0400
Commit:     Alberto Bellotti <abellott>
CommitDate: Tue Sep 20 11:33:35 2016 -0400

    Enhancement to bulk queries to support collection referencing attributes
    
    - Support current name, description, etc.
    - Also support guid if defined in the model.
    - Updated specs
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1352044

 app/controllers/api/base_controller/generic.rb |  6 +++++-
 app/controllers/api/base_controller/manager.rb |  5 ++++-
 app/controllers/api/base_controller/parser.rb  | 13 ++++++-------
 config/api.yml                                 |  4 ++++
 spec/requests/api/collections_spec.rb          | 14 ++++++++++----
 5 files changed, 29 insertions(+), 13 deletions(-)

Comment 5 Martin Kourim 2017-04-10 11:50:51 UTC
Verified on 5.8.0.9-alpha2 that bulk query works on /api/events with "id", "href" and "guid", on /api/users with "name" and "userid", on /api/roles with "name" and on /api/users with "description".