Bug #21087
closedAPI doc for discovery_rule have taxonomy optional but they seem to be required
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://<fwdn>/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://<fqdn>/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"}
Updated by The Foreman Bot about 7 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman_discovery/pull/386 added
Updated by Rahul Bajaj about 7 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset foreman_discovery|d5f330ba3b06804c0b825d6512557e6270e2a076.