-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #57 - add headers
parameter to methods create, update and delete
#58
Conversation
@positiveEV thank you for submitting your first PR. To get it merged you need to fix some small things.
After that I think we can merge the PR as it seems not to interfere the existing test cases. |
header
parameter to methods create, update and delete
header
parameter to methods create, update and deleteheaders
parameter to methods create, update and delete
Signed-off-by: Christian Meißner <cme+github@meissner.sh>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but test case is still missing
Sorry, for not coming back at you earlier. |
No matter. I had some time today to fix some points of the list. Two last things:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work out. If you run pi.get_entity(controller='subnets', controller_path='1', headers={'Content-Type': 'application/xml'})
(after applying the requested change in get_entity
method) you run into an exception.
pi.get_entity(controller='subnets', controller_path='1', headers={'Content-Type': 'application/xml'})
Traceback (most recent call last):
File "/home/cme/.pyenv/versions/phpypam_3.9.11/lib/python3.9/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/home/cme/.pyenv/versions/3.9.11/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/home/cme/.pyenv/versions/3.9.11/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/cme/.pyenv/versions/3.9.11/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/cme/Development/github/username/phpypam/phpypam/core/api.py", line 170, in get_entity
return self._query(token=self._api_token, method=GET, path=_path, params=_params, headers=_headers)
File "/home/cme/Development/github/username/phpypam/phpypam/core/api.py", line 121, in _query
result = resp.json()
File "/home/cme/.pyenv/versions/phpypam_3.9.11/lib/python3.9/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This is related to result = resp.json() in _query
method. You need to refactor this method, otherwise all other methods will break if you use Content-Type: application/xml
.
|
||
if _controller_path: | ||
_path = '{}/{}'.format(_path, _controller_path) | ||
|
||
return self._query(token=self._api_token, method=GET, path=_path, params=_params) | ||
return self._query(token=self._api_token, method=GET, path=_path, params=_params, headers=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an error, you need to pass _headers
here.
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment |
This PR was closed because it has been stalled for 15 days with no activity. |
headers
parameter to methodscreate
,update
anddelete
headers
to internal method_query