netbox-community / pynetbox

Python API client library for Netbox.
Apache License 2.0
567 stars 168 forks source link

Add `core` app to support NetBox 3.5 #541

Closed markkuleinio closed 1 year ago

markkuleinio commented 1 year ago

From NetBox 3.5-beta1 release notes:

The JobResult model has been moved from the extras app to core and renamed to Job. Accordingly, its REST API endpoint has been moved from /api/extras/job-results/ to /api/core/jobs/.

Example (after having created a CheckPrefixLength report and running it):

>>> jobs = list(nb.core.jobs.filter())
>>> jobs
[CheckPrefixLength]
>>> pprint.pprint(dict(jobs[0]))
{'completed': '2023-04-15T23:06:50.380572+03:00',
 'created': '2023-04-15T23:06:50.012358+03:00',
 'data': {'test_prefix_lengths': {'failure': 0,
                                  'info': 4,
                                  'log': [['2023-04-15T20:06:50.074076+00:00',
                                           'info',
                                           '2.2.2.2/32',
                                           '/ipam/ip-addresses/2/',
                                           'No parent prefix'],
                                          ['2023-04-15T20:06:50.379922+00:00',
                                           'info',
                                           '3.3.3.3/32',
                                           '/ipam/ip-addresses/3/',
                                           'No parent prefix'],
                                          ['2023-04-15T20:06:50.380069+00:00',
                                           'info',
                                           '4.4.4.4/32',
                                           '/ipam/ip-addresses/4/',
                                           'No parent prefix'],
                                          ['2023-04-15T20:06:50.380489+00:00',
                                           'info',
                                           '192.168.1.1/24',
                                           '/ipam/ip-addresses/1/',
                                           'No parent prefix']],
                                  'success': 7,
                                  'warning': 0}},
 'display': '845c1a8d-565b-417a-a18e-780f9f64a9ca',
 'id': 3,
 'interval': None,
 'job_id': '845c1a8d-565b-417a-a18e-780f9f64a9ca',
 'name': 'CheckPrefixLength',
 'object_id': 1,
 'object_type': 'extras.reportmodule',
 'scheduled': None,
 'started': '2023-04-15T23:06:50.026913+03:00',
 'status': {'label': 'Completed', 'value': 'completed'},
 'url': 'http://netbox-future.lein.io/api/core/jobs/3/',
 'user': {'display': 'admin',
          'id': 1,
          'url': 'http://netbox-future.lein.io/api/users/users/1/',
          'username': 'admin'}}
>>>
markkuleinio commented 1 year ago

Reference to the pytest.skip() change: https://docs.pytest.org/en/7.1.x/reference/reference.html#pytest.skip

reason (str) – The message to show the user as reason for the skip. msg (Optional[str]) – Same as reason, but deprecated. Will be removed in a future version, use reason instead.

abhi1693 commented 1 year ago

This will be superseded by #564 once that's merged.