Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ body:
attributes:
label: pynetbox version
description: What version of pynetbox are you currently running?
placeholder: v7.1.0
placeholder: v7.4.0
validations:
required: true
- type: input
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
placeholder: v3.6.0
placeholder: v4.0.8
validations:
required: true
- type: dropdown
attributes:
label: Python version
description: What version of Python are you currently running?
options:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
validations:
required: true
- type: textarea
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/py3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
netbox: ["3.4", "3.5", "3.6", "3.7"]
python: ["3.10", "3.11", "3.12"]
netbox: ["3.6", "3.7", "4.0"]

steps:
- uses: actions/checkout@v4
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ Python API client library for [NetBox](https://github.com/netbox-community/netbo

> **Note:** Version 6.7 and later of the library only supports NetBox 3.3 and above.

## Compatibility

Each pyNetBox Version listed below has been tested with its corresponding NetBox Version.

| NetBox Version | Plugin Version |
|:--------------:|:--------------:|
| 4.0.6 | 7.4.0 |
| 4.0.0 | 7.3.4 |
| 3.7 | 7.3.0 |
| 3.6 | 7.2.0 |
| 3.5 | 7.1.0 |
| 3.3 | 7.0.0 |

## Installation

To install run `pip install pynetbox`.
Expand Down
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'pynetbox'
copyright = '2023, NetBox'
author = 'Abhimanyu Saharan'
release = 'Apache2'
project = "pynetbox"
copyright = "2023, NetBox"
author = "Abhimanyu Saharan"
release = "Apache2"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
6 changes: 2 additions & 4 deletions pynetbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from importlib.metadata import version

from pynetbox.core.query import RequestError, AllocationError, ContentError
from pynetbox.core.api import Api as api
from pynetbox.core.query import AllocationError, ContentError, RequestError

__version__ = version(__name__)
__version__ = "7.4.0"
2 changes: 1 addition & 1 deletion pynetbox/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import requests

from pynetbox.core.query import Request
from pynetbox.core.app import App, PluginsApp
from pynetbox.core.query import Request
from pynetbox.core.response import Record


Expand Down
11 changes: 2 additions & 9 deletions pynetbox/core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@

from pynetbox.core.endpoint import Endpoint
from pynetbox.core.query import Request
from pynetbox.models import (
dcim,
ipam,
virtualization,
circuits,
extras,
users,
wireless,
)
from pynetbox.models import (circuits, dcim, extras, ipam, users,
virtualization, wireless)


class App:
Expand Down
1 change: 1 addition & 0 deletions pynetbox/core/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import concurrent.futures as cf
import json

from packaging import version


Expand Down
3 changes: 1 addition & 2 deletions pynetbox/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

import copy
from collections import OrderedDict
from urllib.parse import urlsplit

import pynetbox.core.app
from urllib.parse import urlsplit
from pynetbox.core.query import Request
from pynetbox.core.util import Hashabledict


# List of fields that are lists but should be treated as sets.
LIST_AS_SET = ("tags", "tagged_vlans")

Expand Down
6 changes: 3 additions & 3 deletions pynetbox/models/dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

from urllib.parse import urlsplit

from pynetbox.core.endpoint import DetailEndpoint, RODetailEndpoint
from pynetbox.core.query import Request
from pynetbox.core.response import Record, JsonField
from pynetbox.core.endpoint import RODetailEndpoint, DetailEndpoint
from pynetbox.models.ipam import IpAddresses
from pynetbox.core.response import JsonField, Record
from pynetbox.models.circuits import Circuits
from pynetbox.models.ipam import IpAddresses


class TraceableRecord(Record):
Expand Down
2 changes: 1 addition & 1 deletion pynetbox/models/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
"""

from pynetbox.core.response import Record, JsonField
from pynetbox.core.response import JsonField, Record


class ConfigContexts(Record):
Expand Down
2 changes: 1 addition & 1 deletion pynetbox/models/ipam.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
limitations under the License.
"""

from pynetbox.core.response import Record
from pynetbox.core.endpoint import DetailEndpoint
from pynetbox.core.response import Record


class IpAddresses(Record):
Expand Down
29 changes: 5 additions & 24 deletions pynetbox/models/mapper.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
from .circuits import Circuits, CircuitTerminations
from .dcim import (
DeviceTypes,
Devices,
Interfaces,
PowerOutlets,
PowerPorts,
ConsolePorts,
ConsoleServerPorts,
RackReservations,
VirtualChassis,
FrontPorts,
RearPorts,
Racks,
Termination,
Cables,
)
from .ipam import (
IpAddresses,
Prefixes,
Aggregates,
Vlans,
VlanGroups,
)
from .dcim import (Cables, ConsolePorts, ConsoleServerPorts, Devices,
DeviceTypes, FrontPorts, Interfaces, PowerOutlets,
PowerPorts, RackReservations, Racks, RearPorts, Termination,
VirtualChassis)
from .ipam import Aggregates, IpAddresses, Prefixes, VlanGroups, Vlans
from .virtualization import VirtualMachines
from .wireless import WirelessLans


CONTENT_TYPE_MAPPER = {
"circuits.circuit": Circuits,
"circuits.circuittermination": CircuitTerminations,
Expand Down
2 changes: 1 addition & 1 deletion pynetbox/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
"""

from pynetbox.core.response import Record, JsonField
from pynetbox.core.response import JsonField, Record


class Users(Record):
Expand Down
2 changes: 1 addition & 1 deletion pynetbox/models/virtualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
"""

from pynetbox.core.response import Record, JsonField
from pynetbox.core.response import JsonField, Record
from pynetbox.models.ipam import IpAddresses


Expand Down
18 changes: 7 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
from setuptools import setup, find_packages
from setuptools import find_packages, setup

setup(
name="pynetbox",
description="NetBox API client library",
url="https://github.com/netbox-community/pynetbox",
author="Zach Moody",
author_email="zmoody@do.co",
author="Zach Moody, Arthur Hanson",
author_email="ahanson@netboxlabs.com",
license="Apache2",
include_package_data=True,
use_scm_version=True,
setup_requires=["setuptools_scm"],
packages=find_packages(exclude=["tests", "tests.*"]),
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
install_requires=[
"requests>=2.20.0,<3.0",
"packaging<24.0"
],
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
install_requires=["requests>=2.20.0,<3.0", "packaging<24.0"],
zip_safe=False,
keywords=["netbox"],
classifiers=[
"Intended Audience :: Developers",
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import pytest
from packaging import version


DEFAULT_NETBOX_VERSIONS = "3.7"
DEFAULT_NETBOX_VERSIONS = "4.0"


def pytest_addoption(parser):
Expand Down
19 changes: 7 additions & 12 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import atexit
import os

import subprocess as subp
import time
import yaml
from http.client import RemoteDisconnected

import atexit
import pynetbox
import pytest
import requests
import yaml

import pynetbox

DOCKER_PROJECT_PREFIX = "pytest_pynetbox"

Expand All @@ -27,16 +26,12 @@ def get_netbox_docker_version_tag(netbox_version):
"""
major, minor = netbox_version.major, netbox_version.minor

if (major, minor) == (3, 3):
tag = "2.3.0"
elif (major, minor) == (3, 4):
tag = "2.5.3"
elif (major, minor) == (3, 5):
tag = "2.6.1"
elif (major, minor) == (3, 6):
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"
else:
raise NotImplementedError(
"Version %s is not currently supported" % netbox_version
Expand Down Expand Up @@ -235,7 +230,7 @@ def docker_compose_file(pytestconfig, netbox_docker_repo_dirpaths):
)
compose_data["networks"] = {docker_network_name: {}}
# https://docs.docker.com/compose/compose-file/compose-file-v3/#network-configuration-reference
if compose_data["version"] >= "3.5":
if "version" not in compose_data or compose_data["version"] >= "3.5":
compose_data["networks"][docker_network_name][
"name"
] = docker_network_name
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from unittest.mock import patch

import pynetbox
from .util import Response

from .util import Response

host = "http://localhost:8000"

Expand Down
1 change: 0 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pynetbox


host = "http://localhost:8000"

def_kwargs = {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_circuits.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import unittest
from unittest.mock import patch

from .util import Response
import pynetbox

from .util import Response

api = pynetbox.api(
"http://localhost:8000",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tenancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from unittest.mock import patch

import pynetbox
from .util import Response

from .util import Response

api = pynetbox.api(
"http://localhost:8000",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from unittest.mock import patch

import pynetbox
from .util import Response

from .util import Response

api = pynetbox.api(
"http://localhost:8000",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_virtualization.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import unittest
from unittest.mock import patch

from .util import Response
import pynetbox

from .util import Response

api = pynetbox.api(
"http://localhost:8000",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wireless.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from unittest.mock import patch

import pynetbox
from .util import Response

from .util import Response

api = pynetbox.api("http://localhost:8000")

Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_detailendpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pynetbox


nb = pynetbox.api("http://localhost:8000")


Expand Down
Loading