Description of problem: It makes sense to have an API call to search for a specific package, reporting his status for each consumers. Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
Do you have suggestion or guideline about the API implementation?
I think that this is already possible without any code changes. Can you try to achieve a search like that using the Advanced Search for Consumers [0]? You should be able to form GET style parameters that adhere to the search API [1]. When playing with the API I like to use a tool called pic [2]. Here's a pic hello world example: from pulp.common import pic pic.connect() pic.GET('/pulp/api/v2/consumers/search/') [0]: https://pulp-dev-guide.readthedocs.org/en/latest/integration/rest-api/consumer/retrieval.html#advanced-search-for-consumers [1]: https://pulp-dev-guide.readthedocs.org/en/latest/conventions/criteria.html#search-api [2]: https://github.com/pulp/pulp/blob/master/common/pulp/common/pic.py
Here is an unrelated example, except that it uses the search API. Here is how I search for tasks that are in the running state: from pulp.common import pic pic.connect() body = {"criteria": {"filters": {"state":"running"}}} pic.POST('/pulp/api/v2/tasks/search/', body) The Search API json is used as the payload of the POST to the URL. I wanted to paste this here since I already had it and it is a related example.
I don't think that's possible but i will try to investigate... Tell me if i'm wrong: /pulp/api/v2/tasks/search/ -> search on the 'tasks_status' mongo table /pulp/api/v2/consumers/search/ -> search on the 'consumers' mongo table Is it correct?
After some discussion on IRC it was determined: The URLs in comment 4 don't search on the consumer_unit_profile. Apparently no URL actually provides search on that table so introducing a new URL seems like the right thing to do. I propose the following URL be introduced: /pulp/api/v2/consumers/profile/search/ This is consistent with the existing consumer search URLs for bindings for example: /pulp/api/v2/consumers/binding/search/ Also, since this is a reverse compatible new API change it would need to be introduced in a 2.Y release.
Pull request submitted here: https://github.com/pulp/pulp/pull/1292
Merged to master. QA, please see the docs that were added [0] to test this feature. [0]: http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/consumer/profile.html#searching-profiles
fixed in pulp 2.6.0-0.2.beta
Fails-qa GET worked fine for me but for post doesnt return any respone >>> pic.POST('/v2/consumers/profile/search/',body={"criteria": { "filters": {"profile_name": "screen"},"fields": ["consumer_id","foo"] }}) Request Body { "criteria": { "fields": [ "consumer_id", "foo" ], "filters": { "profile_name": "screen" } } } Response Body [] (200, []) I do have a consumer foo. >>> pic.GET('/v2/consumers/') Response Body [ { "display_name": "foo", "description": null, "_ns": "consumers", "notes": { "_node-update-strategy": "additive", "_child-node": true },
Looks like it was user error. Moving to verified [root@cloud-qe-4 ~]# rpm -qa |grep pulp-server pulp-server-2.6.0-0.5.beta.el7 I used profile_name instead of profile.name When used with profile.name the correct response is given. >>> pic.POST('/v2/consumers/profile/search/',body={"criteria": { "filters": {"profile.name": "screen"},"fields": ["consumer_id","foo"] }}) Request Body { "criteria": { "fields": [ "consumer_id", "foo" ], "filters": { "profile.name": "screen" } } } Response Body [ { "_id": { "$oid": "54cad13f9f9b813d5b604cfc" }, "id": "54cad13f9f9b813d5b604cfc", "consumer_id": "foo" } ] (200, [{u'_id': {u'$oid': u'54cad13f9f9b813d5b604cfc'}, u'id': u'54cad13f9f9b813d5b604cfc', u'consumer_id': u'foo'}])
Moving to verified, as per Preethi's comment.
Moved to https://pulp.plan.io/issues/262