Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-pynetbox for openSUSE:Factory
checked in at 2025-05-26 18:40:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pynetbox (Old)
and /work/SRC/openSUSE:Factory/.python-pynetbox.new.2732 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pynetbox"
Mon May 26 18:40:03 2025 rev:39 rq:1280085 version:7.5.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pynetbox/python-pynetbox.changes
2024-11-17 16:42:01.737301699 +0100
+++
/work/SRC/openSUSE:Factory/.python-pynetbox.new.2732/python-pynetbox.changes
2025-05-26 18:40:55.953019847 +0200
@@ -1,0 +2,10 @@
+Fri May 23 12:17:43 UTC 2025 - Martin Hauke <[email protected]>
+
+- Update to version 7.5.0
+ * Return correct choices when API token can PUT but not POST.
+ * When using OIDC proxy for authentication return correct
+ nb.version property.
+ * Add CircuitTerminations, ConsolePorts, ConsoleServerPorts,
+ PowerOutlets, PowerPorts to trace of circuit.
+
+-------------------------------------------------------------------
Old:
----
pynetbox-7.4.1.tar.gz
New:
----
pynetbox-7.5.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pynetbox.spec ++++++
--- /var/tmp/diff_new_pack.SCdZJR/_old 2025-05-26 18:40:56.589046553 +0200
+++ /var/tmp/diff_new_pack.SCdZJR/_new 2025-05-26 18:40:56.593046721 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-pynetbox
#
-# Copyright (c) 2024 SUSE LLC
+# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,9 +16,9 @@
#
-%define skip_python2 1
+%{?sle15_python_module_pythons}
Name: python-pynetbox
-Version: 7.4.1
+Version: 7.5.0
Release: 0
Summary: NetBox API client library
License: Apache-2.0
++++++ pynetbox-7.4.1.tar.gz -> pynetbox-7.5.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/.github/CODEOWNERS
new/pynetbox-7.5.0/.github/CODEOWNERS
--- old/pynetbox-7.4.1/.github/CODEOWNERS 1970-01-01 01:00:00.000000000
+0100
+++ new/pynetbox-7.5.0/.github/CODEOWNERS 2025-05-20 18:02:53.000000000
+0200
@@ -0,0 +1 @@
+* @arthanson @jnovinger @bctiemann @jeremystretch
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pynetbox-7.4.1/.github/ISSUE_TEMPLATE/bug_report.yaml
new/pynetbox-7.5.0/.github/ISSUE_TEMPLATE/bug_report.yaml
--- old/pynetbox-7.4.1/.github/ISSUE_TEMPLATE/bug_report.yaml 2024-10-25
17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/.github/ISSUE_TEMPLATE/bug_report.yaml 2025-05-20
18:02:53.000000000 +0200
@@ -1,7 +1,7 @@
---
name: 🐛 Bug Report
description: Report a reproducible bug in the current release of pynetbox
-labels: ["type: bug"]
+labels: ["type: bug", "status: needs triage"]
body:
- type: markdown
attributes:
@@ -11,14 +11,14 @@
attributes:
label: pynetbox version
description: What version of pynetbox are you currently running?
- placeholder: v7.4.1
+ placeholder: v7.5.0
validations:
required: true
- type: input
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
- placeholder: v4.0.8
+ placeholder: v4.3.1
validations:
required: true
- type: dropdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pynetbox-7.4.1/.github/ISSUE_TEMPLATE/documentation_change.yaml
new/pynetbox-7.5.0/.github/ISSUE_TEMPLATE/documentation_change.yaml
--- old/pynetbox-7.4.1/.github/ISSUE_TEMPLATE/documentation_change.yaml
2024-10-25 17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/.github/ISSUE_TEMPLATE/documentation_change.yaml
2025-05-20 18:02:53.000000000 +0200
@@ -1,7 +1,7 @@
---
name: 📖 Documentation Change
description: Suggest an addition or modification to the pynetbox documentation
-labels: ["type: documentation"]
+labels: ["type: documentation", "status: needs triage"]
body:
- type: dropdown
attributes:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pynetbox-7.4.1/.github/ISSUE_TEMPLATE/feature_request.yaml
new/pynetbox-7.5.0/.github/ISSUE_TEMPLATE/feature_request.yaml
--- old/pynetbox-7.4.1/.github/ISSUE_TEMPLATE/feature_request.yaml
2024-10-25 17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/.github/ISSUE_TEMPLATE/feature_request.yaml
2025-05-20 18:02:53.000000000 +0200
@@ -1,7 +1,7 @@
---
name: ✨ Feature Request
description: Propose a new pynetbox feature or enhancement
-labels: ["type: feature"]
+labels: ["type: feature", "status: needs triage"]
body:
- type: markdown
attributes:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/.github/workflows/py3.yml
new/pynetbox-7.5.0/.github/workflows/py3.yml
--- old/pynetbox-7.4.1/.github/workflows/py3.yml 2024-10-25
17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/.github/workflows/py3.yml 2025-05-20
18:02:53.000000000 +0200
@@ -13,7 +13,7 @@
strategy:
matrix:
python: ["3.10", "3.11", "3.12"]
- netbox: ["3.6", "3.7", "4.0"]
+ netbox: ["4.1", "4.2", "4.3"]
steps:
- uses: actions/checkout@v4
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/PKG-INFO new/pynetbox-7.5.0/PKG-INFO
--- old/pynetbox-7.4.1/PKG-INFO 2024-10-25 17:59:06.397744200 +0200
+++ new/pynetbox-7.5.0/PKG-INFO 2025-05-20 18:02:57.952609000 +0200
@@ -1,6 +1,6 @@
-Metadata-Version: 2.1
+Metadata-Version: 2.4
Name: pynetbox
-Version: 7.4.1
+Version: 7.5.0
Summary: NetBox API client library
Home-page: https://github.com/netbox-community/pynetbox
Author: Zach Moody, Arthur Hanson
@@ -17,6 +17,17 @@
License-File: LICENSE
Requires-Dist: requests<3.0,>=2.20.0
Requires-Dist: packaging
+Dynamic: author
+Dynamic: author-email
+Dynamic: classifier
+Dynamic: description
+Dynamic: description-content-type
+Dynamic: home-page
+Dynamic: keywords
+Dynamic: license
+Dynamic: license-file
+Dynamic: requires-dist
+Dynamic: summary
# Pynetbox
Python API client library for
[NetBox](https://github.com/netbox-community/netbox).
@@ -29,6 +40,9 @@
| NetBox Version | Plugin Version |
|:--------------:|:--------------:|
+| 4.3 | 7.5.0 |
+| 4.2 | 7.5.0 |
+| 4.1 | 7.5.0 |
| 4.0.6 | 7.4.1 |
| 4.0.0 | 7.3.4 |
| 3.7 | 7.3.0 |
@@ -91,6 +105,30 @@
)
```
+## Running Tests
+
+First, create and activate a Python virtual environment in the pynetbox
directory to isolate the project dependencies:
+
+```python
+python3 -m venv venv
+source venv/bin/activate
+```
+
+Install both requirements files:
+
+```python
+pip install -r requirements.txt
+pip install -r requirements-dev.txt
+```
+
+The test suite requires Docker to be installed and running, as it will
download and launch netbox-docker containers during test execution.
+
+With Docker installed and running, execute the following command to run the
test suite:
+
+```python
+pytest
+```
+
## Alternative Library
> **Note:** For those interested in a different approach, there is an
> alternative Python API client library available for NetBox called
> [netbox-python](https://github.com/netbox-community/netbox-python). This
> library provides a thin Python wrapper over the NetBox API.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/README.md new/pynetbox-7.5.0/README.md
--- old/pynetbox-7.4.1/README.md 2024-10-25 17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/README.md 2025-05-20 18:02:53.000000000 +0200
@@ -9,6 +9,9 @@
| NetBox Version | Plugin Version |
|:--------------:|:--------------:|
+| 4.3 | 7.5.0 |
+| 4.2 | 7.5.0 |
+| 4.1 | 7.5.0 |
| 4.0.6 | 7.4.1 |
| 4.0.0 | 7.3.4 |
| 3.7 | 7.3.0 |
@@ -71,6 +74,30 @@
)
```
+## Running Tests
+
+First, create and activate a Python virtual environment in the pynetbox
directory to isolate the project dependencies:
+
+```python
+python3 -m venv venv
+source venv/bin/activate
+```
+
+Install both requirements files:
+
+```python
+pip install -r requirements.txt
+pip install -r requirements-dev.txt
+```
+
+The test suite requires Docker to be installed and running, as it will
download and launch netbox-docker containers during test execution.
+
+With Docker installed and running, execute the following command to run the
test suite:
+
+```python
+pytest
+```
+
## Alternative Library
> **Note:** For those interested in a different approach, there is an
> alternative Python API client library available for NetBox called
> [netbox-python](https://github.com/netbox-community/netbox-python). This
> library provides a thin Python wrapper over the NetBox API.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/docs/branching.rst
new/pynetbox-7.5.0/docs/branching.rst
--- old/pynetbox-7.4.1/docs/branching.rst 1970-01-01 01:00:00.000000000
+0100
+++ new/pynetbox-7.5.0/docs/branching.rst 2025-05-20 18:02:53.000000000
+0200
@@ -0,0 +1,82 @@
+Branching Plugin
+================
+
+The NetBox branching plugin allows you to create and work with branches in
NetBox, similar to version control systems. This enables you to make changes in
isolation and merge them back to the main branch when ready.
+
+Activating Branches
+-----------------
+
+The `activate_branch` context manager allows you to perform operations within
a specific branch's schema. All operations performed within the context manager
will use that branch's schema.
+
+.. code-block:: python
+
+ import pynetbox
+
+ # Initialize the API
+ nb = pynetbox.api(
+ "http://localhost:8000",
+ token="your-token-here"
+ )
+
+ # Get an existing branch
+ branch = nb.plugins.branching.branches.get(id=1)
+
+ # Activate the branch for operations
+ with nb.activate_branch(branch):
+ # All operations within this block will use the branch's schema
+ sites = nb.dcim.sites.all()
+ # Make changes to objects...
+ # These changes will only exist in this branch
+
+Waiting for Branch Status
+-----------------------
+
+When working with branches, you often need to wait for certain status changes,
such as when a branch becomes ready after creation or when a merge operation
completes. The `tenacity`_ library provides a robust way to handle these
waiting scenarios.
+
+First, install tenacity:
+
+.. code-block:: bash
+
+ pip install tenacity
+
+Here's how to create a reusable function to wait for branch status changes:
+
+.. code-block:: python
+
+ from tenacity import retry, retry_if_result, stop_after_attempt,
wait_exponential
+ import pynetbox
+
+ @retry(
+ stop=stop_after_attempt(30), # Try for up to 30 attempts
+ wait=wait_exponential(
+ multiplier=1, min=4, max=60
+ ), # Wait between 4-60 seconds, increasing exponentially
+ retry=retry_if_result(lambda x: not x), # Retry if the status check
returns False
+ )
+ def wait_for_branch_status(branch, target_status):
+ """Wait for branch to reach a specific status, with exponential
backoff."""
+ branch = nb.plugins.branching.branches.get(branch.id)
+ return str(branch.status) == target_status
+
+ # Example usage:
+ branch = nb.plugins.branching.branches.create(name="my-branch")
+
+ # Wait for branch to be ready
+ wait_for_branch_status(branch, "Ready")
+
+ # Get the latest branch status
+ branch = nb.plugins.branching.branches.get(branch.id)
+ print(f"Branch is now ready! Status: {branch.status}")
+
+The function will:
+1. Check the current status of the branch
+2. If the status doesn't match the target status, it will retry with
exponential backoff
+3. Continue retrying until either:
+ - The branch reaches the target status
+ - The maximum number of attempts (30) is reached
+ - The maximum wait time (60 seconds) is exceeded
+
+The exponential backoff ensures that we don't overwhelm the server with
requests while still checking frequently enough to catch status changes quickly.
+
+.. _tenacity: https://github.com/jd/tenacity
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/docs/development/getting-started.rst
new/pynetbox-7.5.0/docs/development/getting-started.rst
--- old/pynetbox-7.4.1/docs/development/getting-started.rst 1970-01-01
01:00:00.000000000 +0100
+++ new/pynetbox-7.5.0/docs/development/getting-started.rst 2025-05-20
18:02:53.000000000 +0200
@@ -0,0 +1,90 @@
+Getting Started
+==============
+
+This guide will help you get started with development on pynetbox. It covers
setting up your development environment and running tests.
+
+Development Environment
+---------------------
+
+1. Fork the pynetbox repository on GitHub
+2. Clone your fork locally
+3. Create a virtual environment and install development dependencies:
+
+.. code-block:: bash
+
+ python -m venv venv
+ source venv/bin/activate # On Windows: venv\Scripts\activate
+ pip install -e ".[dev]"
+
+Running Tests
+------------
+
+pynetbox uses pytest for testing. The test suite includes both unit tests and
integration tests.
+
+Unit Tests
+~~~~~~~~~
+
+To run the unit tests:
+
+.. code-block:: bash
+
+ pytest tests/unit
+
+Integration Tests
+~~~~~~~~~~~~~~~
+
+The integration tests require a running NetBox instance. The test suite uses
pytest-docker to spin up NetBox instances in Docker containers.
+
+To run the integration tests:
+
+.. code-block:: bash
+
+ pytest tests/integration
+
+You can specify which versions of NetBox to test against using the
`--netbox-versions` flag:
+
+.. code-block:: bash
+
+ pytest tests/integration --netbox-versions 4.1 4.2 4.3
+
+Running Specific Tests
+~~~~~~~~~~~~~~~~~~~~
+
+You can run specific test files or test functions:
+
+.. code-block:: bash
+
+ # Run a specific test file
+ pytest tests/unit/test_api.py
+
+ # Run a specific test function
+ pytest tests/unit/test_api.py::test_api_status
+
+ # Run tests matching a pattern
+ pytest -k "test_api"
+
+Test Coverage
+~~~~~~~~~~~
+
+To run tests with coverage reporting:
+
+.. code-block:: bash
+
+ pytest --cov=pynetbox tests/
+
+Submitting Pull Requests
+----------------------
+
+Once you're happy with your work and have verified that all tests pass, commit
your changes and push it upstream to your fork. Always provide descriptive (but
not excessively verbose) commit messages. Be sure to prefix your commit message
with the word "Fixes" or "Closes" and the relevant issue number (with a hash
mark). This tells GitHub to automatically close the referenced issue once the
commit has been merged.
+
+.. code-block:: bash
+
+ git commit -m "Closes #1234: Add IPv5 support"
+ git push origin
+
+Once your fork has the new commit, submit a pull request to the pynetbox repo
to propose the changes. Be sure to provide a detailed accounting of the changes
being made and the reasons for doing so.
+
+Once submitted, a maintainer will review your pull request and either merge it
or request changes. If changes are needed, you can make them via new commits to
your fork: The pull request will update automatically.
+
+.. warning::
+ Remember, pull requests are permitted only for **accepted** issues. If an
issue you want to work on hasn't been approved by a maintainer yet, it's best
to avoid risking your time and effort on a change that might not be accepted.
(The one exception to this is trivial changes to the documentation or other
non-critical resources.)
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/docs/development/index.rst
new/pynetbox-7.5.0/docs/development/index.rst
--- old/pynetbox-7.4.1/docs/development/index.rst 1970-01-01
01:00:00.000000000 +0100
+++ new/pynetbox-7.5.0/docs/development/index.rst 2025-05-20
18:02:53.000000000 +0200
@@ -0,0 +1,58 @@
+Development
+===========
+
+Thanks for your interest in contributing to pynetbox! This introduction covers
a few important things to know before you get started.
+
+The Code
+--------
+
+pynetbox is maintained on GitHub. GitHub also serves as one of our primary
discussion forums. While all the code and discussion is publicly accessible,
you'll need to register for a free GitHub account to engage in participation.
Most people begin by forking the pynetbox repository under their own GitHub
account to begin working on the code.
+
+There are two permanent branches in the repository:
+
+* `master` - Active development for the upcoming patch release. Pull requests
will typically be based on this branch unless they introduce breaking changes
that must be deferred until the next major release.
+* `feature` - New feature work to be introduced in the next major release.
+
+pynetbox components are arranged into modules:
+
+* `core/` - Core functionality including API interaction, response handling,
and query building
+* `models/` - Model definitions for different NetBox object types
+* `tests/` - Test suite including unit and integration tests
+* `docs/` - Documentation files
+
+Proposing Changes
+---------------
+
+All substantial changes made to the code base are tracked using GitHub issues.
Feature requests, bug reports, and similar proposals must all be filed as
issues and approved by a maintainer before work begins. This ensures that all
changes to the code base are properly documented for future reference.
+
+To submit a new feature request or bug report for pynetbox, select and
complete the appropriate issue template. Once your issue has been approved,
you're welcome to submit a pull request containing your proposed changes.
+
+.. note::
+ Avoid starting work on a proposal before it has been accepted. Not all
proposed changes will be accepted, and we'd hate for you to waste time working
on code that might not make it into the project.
+
+Getting Help
+-----------
+
+There are two primary forums for getting assistance with pynetbox development:
+
+* GitHub discussions - The preferred forum for general discussion and support
issues. Ideal for shaping a feature requests prior to submitting an issue.
+* #netbox on NetDev Community Slack - Good for quick chats. Avoid any
discussion that might need to be referenced later on, as the chat history is
not retained indefinitely.
+
+.. note::
+ Don't use GitHub issues to ask for help: These are reserved for proposed
code changes only.
+
+Governance
+---------
+
+pynetbox follows the benevolent dictator model of governance, with the lead
maintainer ultimately responsible for all changes to the code base. While
community contributions are welcomed and encouraged, the lead maintainer's
primary role is to ensure the project's long-term maintainability and continued
focus on its primary functions.
+
+Licensing
+--------
+
+The entire pynetbox project is licensed as open source under the Apache 2.0
license. This is a very permissive license which allows unlimited
redistribution of all code within the project. Note that all submissions to the
project are subject to the same license.
+
+.. toctree::
+ :maxdepth: 2
+
+ getting-started
+ release-checklist
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pynetbox-7.4.1/docs/development/release-checklist.rst
new/pynetbox-7.5.0/docs/development/release-checklist.rst
--- old/pynetbox-7.4.1/docs/development/release-checklist.rst 1970-01-01
01:00:00.000000000 +0100
+++ new/pynetbox-7.5.0/docs/development/release-checklist.rst 2025-05-20
18:02:53.000000000 +0200
@@ -0,0 +1,54 @@
+Release Checklist
+===============
+
+This document outlines the steps required to prepare and publish a new release
of pynetbox.
+
+Pre-Release Tasks
+---------------
+
+1. Ensure all tests are passing:
+
+ .. code-block:: bash
+
+ pytest
+
+2. Update version number in `pynetbox/__init__.py`
+3. Update documentation for any new features or changes
+4. Check NetBox Docker releases:
+ - Visit https://github.com/netbox-community/netbox-docker/releases
+ - Review the latest NetBox Docker releases and their corresponding NetBox
versions
+ - Update supported NetBox versions in `tests/integration/conftest.py` if
needed
+ - Ensure the `get_netbox_docker_version_tag` function in
`tests/integration/conftest.py` is updated with any new version mappings
+
+Release Tasks
+-----------
+
+1. Create a new release branch from `master`:
+
+ .. code-block:: bash
+
+ git checkout master
+ git pull
+ git checkout -b release/vX.Y.Z
+
+2. Commit version and changelog updates:
+
+ .. code-block:: bash
+
+ git commit -m "Prepare release vX.Y.Z"
+
+3. Create a pull request to merge the release branch into `master`
+4. Once merged, use github to create a new release:
+ - Go to the GitHub repository
+ - Click "Releases" in the right sidebar
+ - Click "Create a new release"
+ - Create a new tag (e.g., vX.Y.Z)
+ - Use the changelog content as the release description
+ - Publish the release
+
+ The GitHub release will automatically trigger the workflow to publish to
PyPI.
+
+Supported NetBox Versions
+----------------------
+
+pynetbox aims to support the current and previous two minor versions of
NetBox. The supported versions are defined in `tests/integration/conftest.py`
and should be updated as part of the release process.
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/docs/index.rst
new/pynetbox-7.5.0/docs/index.rst
--- old/pynetbox-7.4.1/docs/index.rst 2024-10-25 17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/docs/index.rst 2025-05-20 18:02:53.000000000 +0200
@@ -6,7 +6,9 @@
response
request
IPAM
+ branching
advanced
+ development/index
TL;DR
=====
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/pynetbox/__init__.py
new/pynetbox-7.5.0/pynetbox/__init__.py
--- old/pynetbox-7.4.1/pynetbox/__init__.py 2024-10-25 17:59:01.000000000
+0200
+++ new/pynetbox-7.5.0/pynetbox/__init__.py 2025-05-20 18:02:53.000000000
+0200
@@ -1,4 +1,4 @@
from pynetbox.core.api import Api as api
from pynetbox.core.query import AllocationError, ContentError, RequestError
-__version__ = "7.4.1"
+__version__ = "7.5.0"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/pynetbox/core/api.py
new/pynetbox-7.5.0/pynetbox/core/api.py
--- old/pynetbox-7.4.1/pynetbox/core/api.py 2024-10-25 17:59:01.000000000
+0200
+++ new/pynetbox-7.5.0/pynetbox/core/api.py 2025-05-20 18:02:53.000000000
+0200
@@ -14,6 +14,8 @@
limitations under the License.
"""
+import contextlib
+
import requests
from pynetbox.core.app import App, PluginsApp
@@ -110,6 +112,7 @@
"""
version = Request(
base=self.base_url,
+ token=self.token,
http_session=self.http_session,
).get_version()
return version
@@ -207,3 +210,31 @@
# object details will fail
self.token = resp["key"]
return Record(resp, self, None)
+
+ @contextlib.contextmanager
+ def activate_branch(self, branch):
+ """
+ Context manager to activate the branch by setting the schema ID in the
headers.
+
+ :Raises: ValueError if the branch is not a valid NetBox branch.
+
+ :Example:
+
+ >>> import pynetbox
+ >>> nb = pynetbox.api("https://netbox-server")
+ >>> branch = nb.plugins.branching.branches.create(name="testbranch")
+ >>> with nb.activate_branch(branch):
+ ... sites = nb.dcim.sites.all()
+ ... # All operations within this block will use the branch's schema
+ """
+ if not isinstance(branch, Record) or not "schema_id" in dict(branch):
+ raise ValueError(
+ f"The specified branch is not a valid NetBox branch: {branch}."
+ )
+
+ self.http_session.headers["X-NetBox-Branch"] = branch.schema_id
+
+ try:
+ yield
+ finally:
+ self.http_session.headers.pop("X-NetBox-Branch", None)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/pynetbox/core/endpoint.py
new/pynetbox-7.5.0/pynetbox/core/endpoint.py
--- old/pynetbox-7.4.1/pynetbox/core/endpoint.py 2024-10-25
17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/pynetbox/core/endpoint.py 2025-05-20
18:02:53.000000000 +0200
@@ -587,9 +587,10 @@
token=self.api.token,
http_session=self.api.http_session,
).options()
- try:
- post_data = req["actions"]["POST"]
- except KeyError:
+
+ actions = req.get("actions", {})
+ post_data = actions.get("POST") or actions.get("PUT")
+ if post_data is None:
raise ValueError(
"Unexpected format in the OPTIONS response at
{}".format(self.url)
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/pynetbox/models/dcim.py
new/pynetbox-7.5.0/pynetbox/models/dcim.py
--- old/pynetbox-7.4.1/pynetbox/models/dcim.py 2024-10-25 17:59:01.000000000
+0200
+++ new/pynetbox-7.5.0/pynetbox/models/dcim.py 2025-05-20 18:02:53.000000000
+0200
@@ -19,16 +19,22 @@
from pynetbox.core.endpoint import DetailEndpoint, RODetailEndpoint
from pynetbox.core.query import Request
from pynetbox.core.response import JsonField, Record
-from pynetbox.models.circuits import Circuits
+from pynetbox.models.circuits import Circuits, CircuitTerminations
from pynetbox.models.ipam import IpAddresses
class TraceableRecord(Record):
def _get_obj_class(self, url):
uri_to_obj_class_map = {
+ "circuits/circuit-terminations": CircuitTerminations,
"dcim/cables": Cables,
+ "dcim/console-ports": ConsolePorts,
+ "dcim/console-server-ports": ConsoleServerPorts,
"dcim/front-ports": FrontPorts,
"dcim/interfaces": Interfaces,
+ "dcim/power-feeds": PowerFeeds,
+ "dcim/power-outlets": PowerOutlets,
+ "dcim/power-ports": PowerPorts,
"dcim/rear-ports": RearPorts,
}
@@ -154,6 +160,10 @@
interface_connection = InterfaceConnection
+class PowerFeeds(TraceableRecord):
+ pass
+
+
class PowerOutlets(TraceableRecord):
device = Devices
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/pynetbox/models/mapper.py
new/pynetbox-7.5.0/pynetbox/models/mapper.py
--- old/pynetbox-7.4.1/pynetbox/models/mapper.py 2024-10-25
17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/pynetbox/models/mapper.py 2025-05-20
18:02:53.000000000 +0200
@@ -7,6 +7,7 @@
DeviceTypes,
FrontPorts,
Interfaces,
+ PowerFeeds,
PowerOutlets,
PowerPorts,
RackReservations,
@@ -48,7 +49,7 @@
"dcim.modulebaytemplate": None,
"dcim.moduletype": None,
"dcim.platform": None,
- "dcim.powerfeed": None,
+ "dcim.powerfeed": PowerFeeds,
"dcim.poweroutlet": PowerOutlets,
"dcim.poweroutlettemplate": None,
"dcim.powerpanel": None,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/pynetbox.egg-info/PKG-INFO
new/pynetbox-7.5.0/pynetbox.egg-info/PKG-INFO
--- old/pynetbox-7.4.1/pynetbox.egg-info/PKG-INFO 2024-10-25
17:59:06.000000000 +0200
+++ new/pynetbox-7.5.0/pynetbox.egg-info/PKG-INFO 2025-05-20
18:02:57.000000000 +0200
@@ -1,6 +1,6 @@
-Metadata-Version: 2.1
+Metadata-Version: 2.4
Name: pynetbox
-Version: 7.4.1
+Version: 7.5.0
Summary: NetBox API client library
Home-page: https://github.com/netbox-community/pynetbox
Author: Zach Moody, Arthur Hanson
@@ -17,6 +17,17 @@
License-File: LICENSE
Requires-Dist: requests<3.0,>=2.20.0
Requires-Dist: packaging
+Dynamic: author
+Dynamic: author-email
+Dynamic: classifier
+Dynamic: description
+Dynamic: description-content-type
+Dynamic: home-page
+Dynamic: keywords
+Dynamic: license
+Dynamic: license-file
+Dynamic: requires-dist
+Dynamic: summary
# Pynetbox
Python API client library for
[NetBox](https://github.com/netbox-community/netbox).
@@ -29,6 +40,9 @@
| NetBox Version | Plugin Version |
|:--------------:|:--------------:|
+| 4.3 | 7.5.0 |
+| 4.2 | 7.5.0 |
+| 4.1 | 7.5.0 |
| 4.0.6 | 7.4.1 |
| 4.0.0 | 7.3.4 |
| 3.7 | 7.3.0 |
@@ -91,6 +105,30 @@
)
```
+## Running Tests
+
+First, create and activate a Python virtual environment in the pynetbox
directory to isolate the project dependencies:
+
+```python
+python3 -m venv venv
+source venv/bin/activate
+```
+
+Install both requirements files:
+
+```python
+pip install -r requirements.txt
+pip install -r requirements-dev.txt
+```
+
+The test suite requires Docker to be installed and running, as it will
download and launch netbox-docker containers during test execution.
+
+With Docker installed and running, execute the following command to run the
test suite:
+
+```python
+pytest
+```
+
## Alternative Library
> **Note:** For those interested in a different approach, there is an
> alternative Python API client library available for NetBox called
> [netbox-python](https://github.com/netbox-community/netbox-python). This
> library provides a thin Python wrapper over the NetBox API.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/pynetbox.egg-info/SOURCES.txt
new/pynetbox-7.5.0/pynetbox.egg-info/SOURCES.txt
--- old/pynetbox-7.4.1/pynetbox.egg-info/SOURCES.txt 2024-10-25
17:59:06.000000000 +0200
+++ new/pynetbox-7.5.0/pynetbox.egg-info/SOURCES.txt 2025-05-20
18:02:57.000000000 +0200
@@ -6,6 +6,7 @@
requirements-dev.txt
requirements.txt
setup.py
+.github/CODEOWNERS
.github/PULL_REQUEST_TEMPLATE.md
.github/ISSUE_TEMPLATE/bug_report.yaml
.github/ISSUE_TEMPLATE/config.yml
@@ -18,12 +19,16 @@
docs/IPAM.rst
docs/Makefile
docs/advanced.rst
+docs/branching.rst
docs/conf.py
docs/endpoint.rst
docs/index.rst
docs/request.rst
docs/requirements.txt
docs/response.rst
+docs/development/getting-started.rst
+docs/development/index.rst
+docs/development/release-checklist.rst
pynetbox/__init__.py
pynetbox.egg-info/PKG-INFO
pynetbox.egg-info/SOURCES.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/tests/conftest.py
new/pynetbox-7.5.0/tests/conftest.py
--- old/pynetbox-7.4.1/tests/conftest.py 2024-10-25 17:59:01.000000000
+0200
+++ new/pynetbox-7.5.0/tests/conftest.py 2025-05-20 18:02:53.000000000
+0200
@@ -3,7 +3,7 @@
import pytest
from packaging import version
-DEFAULT_NETBOX_VERSIONS = "4.0"
+DEFAULT_NETBOX_VERSIONS = "4.3"
def pytest_addoption(parser):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/tests/integration/conftest.py
new/pynetbox-7.5.0/tests/integration/conftest.py
--- old/pynetbox-7.4.1/tests/integration/conftest.py 2024-10-25
17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/tests/integration/conftest.py 2025-05-20
18:02:53.000000000 +0200
@@ -26,12 +26,12 @@
"""
major, minor = netbox_version.major, netbox_version.minor
- if (major, minor) == (3, 6):
- tag = "2.7.0"
- elif (major, minor) == (3, 7):
- tag = "2.8.0"
- elif (major, minor) == (4, 0):
- tag = "2.9.1"
+ if (major, minor) == (4, 1):
+ tag = "3.0.2"
+ elif (major, minor) == (4, 2):
+ tag = "3.2.0"
+ elif (major, minor) == (4, 3):
+ tag = "3.3.0"
else:
raise NotImplementedError(
"Version %s is not currently supported" % netbox_version
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-7.4.1/tests/unit/test_endpoint.py
new/pynetbox-7.5.0/tests/unit/test_endpoint.py
--- old/pynetbox-7.4.1/tests/unit/test_endpoint.py 2024-10-25
17:59:01.000000000 +0200
+++ new/pynetbox-7.5.0/tests/unit/test_endpoint.py 2025-05-20
18:02:53.000000000 +0200
@@ -60,6 +60,59 @@
self.assertEqual(choices["letter"][1]["display_name"], "B")
self.assertEqual(choices["letter"][1]["value"], 2)
+ def test_choices_put(self):
+ with patch("pynetbox.core.query.Request.options", return_value=Mock())
as mock:
+ api = Mock(base_url="http://localhost:8000/api")
+ app = Mock(name="test")
+ mock.return_value = {
+ "actions": {
+ "PUT": {
+ "letter": {
+ "choices": [
+ {"display_name": "A", "value": 1},
+ {"display_name": "B", "value": 2},
+ {"display_name": "C", "value": 3},
+ ]
+ }
+ }
+ }
+ }
+ test_obj = Endpoint(api, app, "test")
+ choices = test_obj.choices()
+ self.assertEqual(choices["letter"][0]["display_name"], "A")
+ self.assertEqual(choices["letter"][0]["value"], 1)
+
+ def test_choices_precedence(self):
+ with patch("pynetbox.core.query.Request.options", return_value=Mock())
as mock:
+ api = Mock(base_url="http://localhost:8000/api")
+ app = Mock(name="test")
+ mock.return_value = {
+ "actions": {
+ "POST": {
+ "letter": {
+ "choices": [
+ {"display_name": "A", "value": 1},
+ {"display_name": "B", "value": 2},
+ {"display_name": "C", "value": 3},
+ ]
+ }
+ },
+ "PUT": {
+ "letter": {
+ "choices": [
+ {"display_name": "D", "value": 4},
+ {"display_name": "E", "value": 5},
+ {"display_name": "F", "value": 6},
+ ]
+ }
+ },
+ }
+ }
+ test_obj = Endpoint(api, app, "test")
+ choices = test_obj.choices()
+ self.assertEqual(choices["letter"][2]["display_name"], "C")
+ self.assertEqual(choices["letter"][2]["value"], 3)
+
def test_get_with_filter(self):
with patch(
"pynetbox.core.query.Request._make_call", return_value=Mock()