Open miarmak opened 6 years ago
The way that Foreman
generates the functions, takes all the 'implicit' parameters in the url, and makes them part of the signature of the method, that's why on the python code it has two parameters, while the api docs say only one.
Specifically, the host_id
parameter will become part of the url /api/hosts/:host_id/reports/last
, the :host_id
part. While the id
parameter will be sent with the request body.
You could try doing the same request directly with curl or similar, to see if changing the parameters when calling directly the api changes anything. python-foreman
is actually quite dumb in the sense that it does not have any special logic to manage the api, it just autogenerates a set of 'useful' methods.
My guess here is that the method on the foreman side has something unexpected, you can see for example on the docs for the version you are using that it's using a url that is not the one the api exposes:
GET /api/reports/last?expires_at=2016-03-10+15%3A57%3A35+UTC&user=135138680
So I think that at some point the devs wanted to reuse the code from that /api/reports
to generate the endpoint for the hosts, and that it does not work 100% as expected.
You can try asking the foreman devs about it, they are usually very friendly and responsive: http://projects.theforeman.org/projects/foreman/issues
Let me know if you can't reproduce the issue when accessing the api directly, that would mean that python-foreman
is messing something up in between.
Thanks!
Thanks a lot for such a detailed response!
I've tried to access Foreman API directly via curl
and it doesn't use this id
parameter. Here how it looks like for me (and works):
curl -u <user>:<pass> -k https://<foreman_ip>/api/hosts/<host_id>/reports/last
So there's only a place for host_id
parameter, but not for id
. I assume, that there's kind of a typo in the Foreman API docs and this id
parameter is actually a host_id
one.
Thanks!
There is a method of
foreman.client.Foreman()
:hosts.reports_last
.The
help
function output for it states, that the method takes 2 arguments:host_id
andid
, that are both required:Indicating different values in this argument lead to the same results. And also official Foreman API documentation states, that this method takes only 1 parameter -
host_id
: https://theforeman.org/api/1.8/apidoc/v2/reports/last.html. But I can see similar description in that doc and this method here for 'id' parameter. In this case I assume it could incorrectly generated.Foreman version:
1.11.4
python-foreman:0.4.19