Bug #21087

API doc for discovery_rule have taxonomy optional but they seem to be required

Added by Lukas Zapletal 8 months ago. Updated 7 months ago.

Status:Closed
Priority:Normal
Assigned To:Rahul Bajaj
Category:Discovery plugin
Target version:Foreman - Team Anurag Iteration 21
Difficulty: Pull request:https://github.com/theforeman/foreman_discovery/pull/386
Bugzilla link:1494585
Story points-
Velocity based estimate-

Description

API doc for discovery_rule says both "discovery_rule[location_ids]" and "discovery_rule[organization_ids]" are optional but they seem to be required

Steps to Reproduce:
1. Have host group with ID 1 which links to default org (id 1) and default
loc (id 2)
2. Attempt to create discovery rule and use only required fields as per
documentation
$ curl -k -u <user>:<pass> -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' https://&lt;fwdn&gt;/api/v2/discovery_rules/ -d '{"discovery_rule":{"name":"MyDiscoveryRuleFromApi","search":"cpu_count=10","hostgroup_id":1}}' {
"error": {"id":null,"errors":{"organizations":["Host group organization Default Organization must also be associated to the discovery rule"],"locations":["Host group location Default Location must also be associated to the discovery rule"]},"full_messages":["Organizations Host group organization Default Organization must also be associated to the discovery rule","Locations Host group location Default Location must also be associated to the discovery rule"]}
}

Actual results:
Error above.

Expected results:
Either error should not be there, or documentation should say these two fields are required.

Additional info:
With both of these fields, it works
$ curl -k -u <user>:<pass> -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' https://&lt;fqdn&gt;/api/v2/discovery_rules/ -d '{"discovery_rule":{"name":"MyDiscoveryRuleFromApi","search":"cpu_count=10","hostgroup_id":1,"organization_ids":[1],"location_ids":[2]}}' {"id":8,"name":"MyDiscoveryRuleFromApi","search":"cpu_count=10","hostgroup_id":1,"hostname":"","max_count":0,"priority":0,"enabled":true,"created_at":"2017-09-22T14:30:13.913Z","updated_at":"2017-09-22T14:30:13.913Z"}

Associated revisions

Revision d5f330ba
Added by Rahul Bajaj 7 months ago

Fixes #21087 - Correct Api doc for discovery rules

History

#1 Updated by Rahul Bajaj 8 months ago

  • Assigned To set to Rahul Bajaj

#2 Updated by The Foreman Bot 8 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman_discovery/pull/386 added

#3 Updated by Rahul Bajaj 8 months ago

  • Target version set to Team Anurag Iteration 21

#4 Updated by Rahul Bajaj 7 months ago

  • % Done changed from 0 to 100
  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF