netbox-community / pynetbox

Python API client library for Netbox.
Apache License 2.0
543 stars 167 forks source link

ObjectChanges Log is calling the wrong API endpoint #551

Closed jchambers2012 closed 1 year ago

jchambers2012 commented 1 year ago

When calling nb.extras.ObjectChanges.all() function to get changes that have happened. It is calling /api/extras/ObjectChanges/ when I believe it should be calling /api/extras/object-changes/

image

2023-05-02 11:43:12,363 | test_netbox_api | INFO | Started
2023-05-02 11:43:12,363 | test_netbox_api | INFO | setting up api
2023-05-02 11:43:12,367 | test_netbox_api | INFO | object = <pynetbox.core.api.Api object at 0x000001E195BAFF70>
<pynetbox.core.response.RecordSet object at 0x000001E195D40700>
Traceback (most recent call last):
  File "\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File ".vscode\extensions\ms-python.python-2023.6.1\pythonFiles\lib\python\debugpy\__main__.py", line 39, in <module>     
    cli.main()
  File ".vscode\extensions\ms-python.python-2023.6.1\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File ".vscode\extensions\ms-python.python-2023.6.1\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File ".vscode\extensions\ms-python.python-2023.6.1\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File ".vscode\extensions\ms-python.python-2023.6.1\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File ".vscode\extensions\ms-python.python-2023.6.1\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "C:\Temp\DCN3.0-lab\python_scripts\test_netbox_api.py", line 37, in <module>
    for change in changes:
  File "\Python\Python310\lib\site-packages\pynetbox\core\response.py", line 127, in __next__        
    next(self.response), self.endpoint.api, self.endpoint
  File "\Python\Python310\lib\site-packages\pynetbox\core\query.py", line 280, in get
    req = self._make_call(add_params=add_params)
  File "\Python\Python310\lib\site-packages\pynetbox\core\query.py", line 247, in _make_call
    raise RequestError(req)
pynetbox.core.query.RequestError: The requested url: http://xxxxxxxx:8000/api/extras/ObjectChanges/?limit=0 could not be found.

Let me know if you need more details

markkuleinio commented 1 year ago

/api/extras/object-changes/ -> nb.extras.object_changes.filter()

Also note that .all() has been deprecated as mentioned in https://github.com/netbox-community/pynetbox/releases/tag/v6.3.0, use .filter() instead for future-proof code.

jchambers2012 commented 1 year ago

that was the fix - sorry for the noise