././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.226451 pynetbox-7.0.0/0000755000175100001730000000000014344673035013000 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2104506 pynetbox-7.0.0/.github/0000755000175100001730000000000014344673035014340 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2104506 pynetbox-7.0.0/.github/workflows/0000755000175100001730000000000014344673035016375 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/.github/workflows/publish.yml0000644000175100001730000000154114344673022020563 0ustar00runnerdocker# This workflows will upload a Python Package using Twine when a release is created # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries name: Upload Python Package on: release: types: [created] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.x' - name: Install dependencies run: | python -m pip install --upgrade pip pip install setuptools wheel twine - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | python setup.py sdist bdist_wheel twine upload dist/* ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/.github/workflows/py3.yml0000644000175100001730000000120414344673022017624 0ustar00runnerdockername: Py3 Test on: pull_request: {} push: branches: - master jobs: build: runs-on: ubuntu-latest strategy: matrix: python: ["3.8", "3.9", "3.10"] netbox: ["3.3"] steps: - uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} - name: Install dev requirements run: pip install -r requirements-dev.txt . - name: Run Linter run: black --diff --check pynetbox tests - name: Run Tests run: pytest --netbox-versions=${{ matrix.netbox }} ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/.gitignore0000644000175100001730000000236314344673022014770 0ustar00runnerdocker# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib64/ lib/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ # Other git repos checked out locally .netbox-docker-*/ .devicetype-library/ # Visual Studio Code settings .vscode/ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/CHANGELOG.md0000644000175100001730000000012714344673022014605 0ustar00runnerdocker For the list of changelog, please see the repository releases information in GitHub. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/LICENSE0000644000175100001730000002261414344673022014006 0ustar00runnerdocker Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS Copyright 2017 DigitalOcean././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.226451 pynetbox-7.0.0/PKG-INFO0000644000175100001730000000103614344673035014075 0ustar00runnerdockerMetadata-Version: 2.1 Name: pynetbox Version: 7.0.0 Summary: NetBox API client library Home-page: https://github.com/netbox-community/netbox Author: Zach Moody Author-email: zmoody@do.co License: Apache2 Keywords: netbox Classifier: Intended Audience :: Developers Classifier: Development Status :: 5 - Production/Stable Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 License-File: LICENSE ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/README.md0000644000175100001730000000372514344673022014262 0ustar00runnerdocker# Pynetbox Python API client library for [NetBox](https://github.com/netbox-community/netbox). > **Note:** Version 6.7 and later of the library only supports NetBox 3.3 and above. ## Installation To install run `pip install pynetbox`. Alternatively, you can clone the repo and run `python setup.py install`. ## Quick Start The full pynetbox API is documented on [Read the Docs](http://pynetbox.readthedocs.io/en/latest/), but the following should be enough to get started using it. To begin, import pynetbox and instantiate the API. ``` import pynetbox nb = pynetbox.api( 'http://localhost:8000', private_key_file='/path/to/private-key.pem', token='d6f4e314a5b5fefd164995169f28ae32d987704f' ) ``` The first argument the .api() method takes is the NetBox URL. There are a handful of named arguments you can provide, but in most cases none are required to simply pull data. In order to write, the `token` argument should to be provided. To decrypt information from the `secrets` endpoint either the `private_key_file` or `private_key` argument needs to be provided. ## Queries The pynetbox API is setup so that NetBox's apps are attributes of the `.api()` object, and in turn those apps have attribute representing each endpoint. Each endpoint has a handful of methods available to carry out actions on the endpoint. For example, in order to query all the objects in the `devices` endpoint you would do the following: ``` >>> devices = nb.dcim.devices.all() >>> for device in devices: ... print(device.name) ... test1-leaf1 test1-leaf2 test1-leaf3 >>> ``` ### Threading pynetbox supports multithreaded calls for `.filter()` and `.all()` queries. It is **highly recommended** you have `MAX_PAGE_SIZE` in your Netbox install set to anything *except* `0` or `None`. The default value of `1000` is usually a good value to use. To enable threading, add `threading=True` parameter to the `.api`: ```python nb = pynetbox.api( 'http://localhost:8000', threading=True, ) ``` ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2104506 pynetbox-7.0.0/docs/0000755000175100001730000000000014344673035013730 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/docs/IPAM.rst0000644000175100001730000000020414344673022015200 0ustar00runnerdockerIPAM ======== .. autoclass:: pynetbox.models.ipam.Prefixes :members: .. autoclass:: pynetbox.models.ipam.VlanGroups :members: ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/docs/Makefile0000644000175100001730000000113514344673022015364 0ustar00runnerdocker# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build SPHINXPROJ = pynetbox SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/docs/advanced.rst0000644000175100001730000000372414344673022016231 0ustar00runnerdockerCustom Sessions =============== Custom sessions can be used to modify the default HTTP behavior. Below are a few examples, most of them from `here `_. Headers ******* To set a custom header on all requests. These headers are automatically merged with headers pynetbox sets itself. :Example: >>> import pynetbox >>> import requests >>> session = requests.Session() >>> session.headers = {"mycustomheader": "test"} >>> nb = pynetbox.api( ... 'http://localhost:8000', ... private_key_file='/path/to/private-key.pem', ... token='d6f4e314a5b5fefd164995169f28ae32d987704f' ... ) >>> nb.http_session = session SSL Verification **************** To disable SSL verification. See `the docs `_. :Example: >>> import pynetbox >>> import requests >>> session = requests.Session() >>> session.verify = False >>> nb = pynetbox.api( ... 'http://localhost:8000', ... private_key_file='/path/to/private-key.pem', ... token='d6f4e314a5b5fefd164995169f28ae32d987704f' ... ) >>> nb.http_session = session Timeouts ******** Setting timeouts requires the use of Adapters. :Example: .. code-block:: python from requests.adapters import HTTPAdapter class TimeoutHTTPAdapter(HTTPAdapter): def __init__(self, *args, **kwargs): self.timeout = kwargs.get("timeout", 5) super().__init__(*args, **kwargs) def send(self, request, **kwargs): kwargs['timeout'] = self.timeout return super().send(request, **kwargs) adapter = TimeoutHTTPAdapter() session = requests.Session() session.mount("http://", adapter) session.mount("https://", adapter) nb = pynetbox.api( 'http://localhost:8000', private_key_file='/path/to/private-key.pem', token='d6f4e314a5b5fefd164995169f28ae32d987704f' ) nb.http_session = session ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/docs/conf.py0000644000175100001730000001152614344673022015230 0ustar00runnerdocker# -*- coding: utf-8 -*- # # pynetbox documentation build configuration file, created by # sphinx-quickstart on Thu Apr 6 22:31:03 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # import os import sys from pkg_resources import get_distribution sys.path.insert(0, os.path.abspath("../")) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = ["sphinx.ext.autodoc"] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = ".rst" # The master toctree document. master_doc = "index" # General information about the project. project = "pynetbox" copyright = "2017, DigitalOcean" author = "Zach Moody" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # The full version, including alpha/beta/rc tags. release = get_distribution("pynetbox").version # # The short X.Y version. version = ".".join(release.split(".")[:2]) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # # html_theme = 'classic' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". # html_static_path = ['_static'] html_sidebars = { "**": ["globaltoc.html", "relations.html", "sourcelink.html", "searchbox.html"] } # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. htmlhelp_basename = "pynetboxdoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, "pynetbox.tex", "pynetbox Documentation", "Zach Moody", "manual"), ] # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [(master_doc, "pynetbox", "pynetbox Documentation", [author], 1)] # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ( master_doc, "pynetbox", "pynetbox Documentation", author, "pynetbox", "A python library for NetBox.", "Miscellaneous", ), ] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/docs/endpoint.rst0000644000175100001730000000021714344673022016276 0ustar00runnerdockerEndpoint ======== .. autoclass:: pynetbox.core.endpoint.Endpoint :members: .. autoclass:: pynetbox.core.endpoint.DetailEndpoint :members:././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/docs/index.rst0000644000175100001730000000063214344673022015566 0ustar00runnerdocker.. toctree:: :maxdepth: 2 :caption: Contents: endpoint response request IPAM TL;DR ===== Instantiate the :py:class:`.Api`. Use the methods available on :py:class:`.Endpoint` to return :py:class:`.Record` objects. API === .. autoclass:: pynetbox.core.api.Api :members: App === .. autoclass:: pynetbox.core.app.App :members: Indices and tables ================== * :ref:`genindex` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/docs/request.rst0000644000175100001730000000031314344673022016143 0ustar00runnerdockerRequest ======== .. autoclass:: pynetbox.core.query.RequestError :members: .. autoclass:: pynetbox.core.query.ContentError :members: .. autoclass:: pynetbox.core.query.AllocationError :members: ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/docs/response.rst0000644000175100001730000000021114344673022016306 0ustar00runnerdockerResponse ======== .. autoclass:: pynetbox.core.response.Record :members: .. autoclass:: pynetbox.core.response.RecordSet :members: ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2104506 pynetbox-7.0.0/pynetbox/0000755000175100001730000000000014344673035014650 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/__init__.py0000644000175100001730000000043014344673022016752 0ustar00runnerdockerfrom pkg_resources import get_distribution, DistributionNotFound from pynetbox.core.query import RequestError, AllocationError, ContentError from pynetbox.core.api import Api as api try: __version__ = get_distribution(__name__).version except DistributionNotFound: pass ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2144508 pynetbox-7.0.0/pynetbox/core/0000755000175100001730000000000014344673035015600 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/core/__init__.py0000644000175100001730000000000014344673022017673 0ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/core/api.py0000644000175100001730000001722314344673022016724 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import requests from pynetbox.core.query import Request from pynetbox.core.app import App, PluginsApp from pynetbox.core.response import Record class Api: """The API object is the point of entry to pynetbox. After instantiating the Api() with the appropriate named arguments you can specify which app and endpoint you wish to interact with. Valid attributes currently are: * dcim * ipam * circuits * secrets (on NetBox 2.11 and older) * tenancy * extras * virtualization * users (since NetBox 2.9) * wireless (since NetBox 3.1) Calling any of these attributes will return :py:class:`.App` which exposes endpoints as attributes. **Additional Attributes**: * **http_session(requests.Session)**: Override the default session with your own. This is used to control a number of HTTP behaviors such as SSL verification, custom headers, retires, and timeouts. See `custom sessions `__ for more info. :param str url: The base URL to the instance of NetBox you wish to connect to. :param str token: Your NetBox token. :param str,optional private_key_file: The path to your private key file. (Usable only on NetBox 2.11 and older) :param str,optional private_key: Your private key. (Usable only on NetBox 2.11 and older) :param bool,optional threading: Set to True to use threading in ``.all()`` and ``.filter()`` requests. :raises ValueError: If *private_key* and *private_key_file* are both specified. :raises AttributeError: If app doesn't exist. :Examples: >>> import pynetbox >>> nb = pynetbox.api( ... 'http://localhost:8000', ... token='d6f4e314a5b5fefd164995169f28ae32d987704f' ... ) >>> list(nb.dcim.devices.all()) [test1-leaf1, test1-leaf2, test1-leaf3] """ def __init__( self, url, token=None, private_key=None, private_key_file=None, threading=False, ): if private_key and private_key_file: raise ValueError( '"private_key" and "private_key_file" cannot be used together.' ) base_url = "{}/api".format(url if url[-1] != "/" else url[:-1]) self.token = token self.private_key = private_key self.private_key_file = private_key_file self.base_url = base_url self.session_key = None self.http_session = requests.Session() self.threading = threading if self.private_key_file: with open(self.private_key_file, "r") as kf: private_key = kf.read() self.private_key = private_key self.dcim = App(self, "dcim") self.ipam = App(self, "ipam") self.circuits = App(self, "circuits") self.secrets = App(self, "secrets") self.tenancy = App(self, "tenancy") self.extras = App(self, "extras") self.virtualization = App(self, "virtualization") self.users = App(self, "users") self.wireless = App(self, "wireless") self.plugins = PluginsApp(self) @property def version(self): """Gets the API version of NetBox. Can be used to check the NetBox API version if there are version-dependent features or syntaxes in the API. :Returns: Version number as a string. :Example: >>> import pynetbox >>> nb = pynetbox.api( ... 'http://localhost:8000', ... token='d6f4e314a5b5fefd164995169f28ae32d987704f' ... ) >>> nb.version '3.1' >>> """ version = Request( base=self.base_url, http_session=self.http_session, ).get_version() return version def openapi(self): """Returns the OpenAPI spec. Quick helper function to pull down the entire OpenAPI spec. :Returns: dict :Example: >>> import pynetbox >>> nb = pynetbox.api( ... 'http://localhost:8000', ... token='d6f4e314a5b5fefd164995169f28ae32d987704f' ... ) >>> nb.openapi() {...} >>> """ return Request( base=self.base_url, http_session=self.http_session, ).get_openapi() def status(self): """Gets the status information from NetBox. Available in NetBox 2.10.0 or newer. :Returns: Dictionary as returned by NetBox. :Raises: :py:class:`.RequestError` if the request is not successful. :Example: >>> pprint.pprint(nb.status()) {'django-version': '3.1.3', 'installed-apps': {'cacheops': '5.0.1', 'debug_toolbar': '3.1.1', 'django_filters': '2.4.0', 'django_prometheus': '2.1.0', 'django_rq': '2.4.0', 'django_tables2': '2.3.3', 'drf_yasg': '1.20.0', 'mptt': '0.11.0', 'rest_framework': '3.12.2', 'taggit': '1.3.0', 'timezone_field': '4.0'}, 'netbox-version': '2.10.2', 'plugins': {}, 'python-version': '3.7.3', 'rq-workers-running': 1} >>> """ status = Request( base=self.base_url, token=self.token, http_session=self.http_session, ).get_status() return status def create_token(self, username, password): """Creates an API token using a valid NetBox username and password. Saves the created token automatically in the API object. Requires NetBox 3.0.0 or newer. :Returns: The token as a ``Record`` object. :Raises: :py:class:`.RequestError` if the request is not successful. :Example: >>> import pynetbox >>> nb = pynetbox.api("https://netbox-server") >>> token = nb.create_token("admin", "netboxpassword") >>> nb.token '96d02e13e3f1fdcd8b4c089094c0191dcb045bef' >>> from pprint import pprint >>> pprint(dict(token)) {'created': '2021-11-27T11:26:49.360185+02:00', 'description': '', 'display': '045bef (admin)', 'expires': None, 'id': 2, 'key': '96d02e13e3f1fdcd8b4c089094c0191dcb045bef', 'url': 'https://netbox-server/api/users/tokens/2/', 'user': {'display': 'admin', 'id': 1, 'url': 'https://netbox-server/api/users/users/1/', 'username': 'admin'}, 'write_enabled': True} >>> """ resp = Request( base="{}/users/tokens/provision/".format(self.base_url), http_session=self.http_session, ).post(data={"username": username, "password": password}) # Save the newly created API token, otherwise populating the Record # object details will fail self.token = resp["key"] return Record(resp, self, None) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/core/app.py0000644000175100001730000001415514344673022016734 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from pynetbox.core.endpoint import Endpoint from pynetbox.core.query import Request from pynetbox.models import ( dcim, ipam, virtualization, circuits, extras, users, wireless, ) class App: """Represents apps in NetBox. Calls to attributes are returned as Endpoint objects. :returns: :py:class:`.Endpoint` matching requested attribute. :raises: :py:class:`.RequestError` if requested endpoint doesn't exist. """ def __init__(self, api, name): self.api = api self.name = name self._choices = None self._setmodel() models = { "dcim": dcim, "ipam": ipam, "circuits": circuits, "virtualization": virtualization, "extras": extras, "users": users, "wireless": wireless, } def _setmodel(self): self.model = App.models[self.name] if self.name in App.models else None def __getstate__(self): return {"api": self.api, "name": self.name, "_choices": self._choices} def __setstate__(self, d): self.__dict__.update(d) self._setmodel() def __getattr__(self, name): if name == "secrets": self._set_session_key() return Endpoint(self.api, self, name, model=self.model) def _set_session_key(self): if getattr(self.api, "session_key"): return if self.api.token and self.api.private_key: self.api.session_key = Request( base=self.api.base_url, token=self.api.token, private_key=self.api.private_key, http_session=self.api.http_session, ).get_session_key() def choices(self): """Returns _choices response from App .. note:: This method is deprecated and only works with NetBox version 2.7.x or older. The ``choices()`` method in :py:class:`.Endpoint` is compatible with all NetBox versions. :Returns: Raw response from NetBox's _choices endpoint. """ if self._choices: return self._choices self._choices = Request( base="{}/{}/_choices/".format(self.api.base_url, self.name), token=self.api.token, private_key=self.api.private_key, http_session=self.api.http_session, ).get() return self._choices def custom_choices(self): """Returns _custom_field_choices response from app .. note:: This method only works with NetBox version 2.9.x or older. NetBox 2.10.0 introduced the ``/extras/custom-fields/`` endpoint that can be used f.ex. like ``nb.extras.custom_fields.all()``. :Returns: Raw response from NetBox's _custom_field_choices endpoint. :Raises: :py:class:`.RequestError` if called for an invalid endpoint. :Example: >>> nb.extras.custom_choices() {'Testfield1': {'Testvalue2': 2, 'Testvalue1': 1}, 'Testfield2': {'Othervalue2': 4, 'Othervalue1': 3}} """ custom_field_choices = Request( base="{}/{}/_custom_field_choices/".format( self.api.base_url, self.name, ), token=self.api.token, private_key=self.api.private_key, http_session=self.api.http_session, ).get() return custom_field_choices def config(self): """Returns config response from app :Returns: Raw response from NetBox's config endpoint. :Raises: :py:class:`.RequestError` if called for an invalid endpoint. :Example: >>> pprint.pprint(nb.users.config()) {'tables': {'DeviceTable': {'columns': ['name', 'status', 'tenant', 'device_role', 'site', 'primary_ip', 'tags']}}} """ config = Request( base="{}/{}/config/".format( self.api.base_url, self.name, ), token=self.api.token, private_key=self.api.private_key, http_session=self.api.http_session, ).get() return config class PluginsApp: """ Basically valid plugins api could be handled by same App class, but you need to add plugins to request url path. :returns: :py:class:`.App` with added plugins into path. """ def __init__(self, api): self.api = api def __getstate__(self): return self.__dict__ def __setstate__(self, d): self.__dict__.update(d) def __getattr__(self, name): return App(self.api, "plugins/{}".format(name.replace("_", "-"))) def installed_plugins(self): """Returns raw response with installed plugins :returns: Raw response NetBox's installed plugins. :Example: >>> nb.plugins.installed_plugins() [{ 'name': 'test_plugin', 'package': 'test_plugin', 'author': 'Dmitry', 'description': 'Netbox test plugin', 'verison': '0.10' }] """ installed_plugins = Request( base="{}/plugins/installed-plugins".format( self.api.base_url, ), token=self.api.token, private_key=self.api.private_key, http_session=self.api.http_session, ).get() return installed_plugins ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/core/endpoint.py0000644000175100001730000005023114344673022017767 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from pynetbox.core.query import Request, RequestError from pynetbox.core.response import Record, RecordSet RESERVED_KWARGS = () class Endpoint: """Represent actions available on endpoints in the Netbox API. Takes ``name`` and ``app`` passed from App() and builds the correct url to make queries to and the proper Response object to return results in. :arg obj api: Takes :py:class:`.Api` created at instantiation. :arg obj app: Takes :py:class:`.App`. :arg str name: Name of endpoint passed to App(). :arg obj,optional model: Custom model for given app. .. note:: In order to call NetBox endpoints with dashes in their names you should convert the dash to an underscore. (E.g. querying the ip-addresses endpoint is done with ``nb.ipam.ip_addresses.all()``.) """ def __init__(self, api, app, name, model=None): self.return_obj = self._lookup_ret_obj(name, model) self.name = name.replace("_", "-") self.api = api self.base_url = api.base_url self.token = api.token self.session_key = api.session_key self.url = "{base_url}/{app}/{endpoint}".format( base_url=self.base_url, app=app.name, endpoint=self.name, ) self._choices = None def _lookup_ret_obj(self, name, model): """Loads unique Response objects. This method loads a unique response object for an endpoint if it exists. Otherwise return a generic `Record` object. :arg str name: Endpoint name. :arg obj model: The application model that contains unique Record objects. :Returns: Record (obj) """ if model: name = name.title().replace("_", "") ret = getattr(model, name, Record) else: ret = Record return ret def all(self, limit=0, offset=None): """Queries the 'ListView' of a given endpoint. Returns all objects from an endpoint. :arg int,optional limit: Overrides the max page size on paginated returns. :arg int,optional offset: Overrides the offset on paginated returns. :Returns: A :py:class:`.RecordSet` object. :Examples: >>> devices = nb.dcim.devices.all() >>> for device in devices: ... print(device.name) ... test1-leaf1 test1-leaf2 test1-leaf3 >>> """ if limit == 0 and offset is not None: raise ValueError("offset requires a positive limit value") req = Request( base="{}/".format(self.url), token=self.token, session_key=self.session_key, http_session=self.api.http_session, threading=self.api.threading, limit=limit, offset=offset, ) return RecordSet(self, req) def get(self, *args, **kwargs): r"""Queries the DetailsView of a given endpoint. :arg int,optional key: id for the item to be retrieved. :arg str,optional \**kwargs: Accepts the same keyword args as filter(). Any search argument the endpoint accepts can be added as a keyword arg. :returns: A single :py:class:`.Record` object or None :raises ValueError: if kwarg search return more than one value. :Examples: Referencing with a kwarg that only returns one value. >>> nb.dcim.devices.get(name='test1-a3-tor1b') test1-a3-tor1b >>> Referencing with an id. >>> nb.dcim.devices.get(1) test1-edge1 >>> """ try: key = args[0] except IndexError: key = None if not key: resp = self.filter(**kwargs) ret = next(resp, None) if not ret: return ret try: next(resp) raise ValueError( "get() returned more than one result. " "Check that the kwarg(s) passed are valid for this " "endpoint or use filter() or all() instead." ) except StopIteration: return ret req = Request( key=key, base=self.url, token=self.token, session_key=self.session_key, http_session=self.api.http_session, ) try: return next(RecordSet(self, req), None) except RequestError as e: if e.req.status_code == 404: return None else: raise e def filter(self, *args, **kwargs): r"""Queries the 'ListView' of a given endpoint. Takes named arguments that match the usable filters on a given endpoint. If an argument is passed then it's used as a freeform search argument if the endpoint supports it. :arg str,optional \*args: Freeform search string that's accepted on given endpoint. :arg str,optional \**kwargs: Any search argument the endpoint accepts can be added as a keyword arg. :arg int,optional limit: Overrides the max page size on paginated returns. :arg int,optional offset: Overrides the offset on paginated returns. :Returns: A :py:class:`.RecordSet` object. :Examples: To return a list of objects matching a named argument filter. >>> devices = nb.dcim.devices.filter(role='leaf-switch') >>> for device in devices: ... print(device.name) ... test1-leaf1 test1-leaf2 test1-leaf3 >>> Using a freeform query along with a named argument. >>> devices = nb.dcim.devices.filter('a3', role='leaf-switch') >>> for device in devices: ... print(device.name) ... test1-a3-leaf1 test1-a3-leaf2 >>> Chaining multiple named arguments. >>> devices = nb.dcim.devices.filter(role='leaf-switch', status=True) >>> for device in devices: ... print(device.name) ... test1-leaf2 >>> Passing a list as a named argument adds multiple filters of the same value. >>> devices = nb.dcim.devices.filter(role=['leaf-switch', 'spine-switch']) >>> for device in devices: ... print(device.name) ... test1-a3-spine1 test1-a3-spine2 test1-a3-leaf1 >>> """ if args: kwargs.update({"q": args[0]}) if any(i in RESERVED_KWARGS for i in kwargs): raise ValueError( "A reserved kwarg was passed ({}). Please remove it " "and try again.".format(RESERVED_KWARGS) ) limit = kwargs.pop("limit") if "limit" in kwargs else 0 offset = kwargs.pop("offset") if "offset" in kwargs else None if limit == 0 and offset is not None: raise ValueError("offset requires a positive limit value") req = Request( filters=kwargs, base=self.url, token=self.token, session_key=self.session_key, http_session=self.api.http_session, threading=self.api.threading, limit=limit, offset=offset, ) return RecordSet(self, req) def create(self, *args, **kwargs): r"""Creates an object on an endpoint. Allows for the creation of new objects on an endpoint. Named arguments are converted to json properties, and a single object is created. NetBox's bulk creation capabilities can be used by passing a list of dictionaries as the first argument. .. note: Any positional arguments will supercede named ones. :arg list \*args: A list of dictionaries containing the properties of the objects to be created. :arg str \**kwargs: key/value strings representing properties on a json object. :returns: A list or single :py:class:`.Record` object depending on whether a bulk creation was requested. :Examples: Creating an object on the `devices` endpoint: >>> device = netbox.dcim.devices.create( ... name='test', ... device_role=1, ... ) >>> Use bulk creation by passing a list of dictionaries: >>> nb.dcim.devices.create([ ... { ... "name": "test1-core3", ... "device_role": 3, ... "site": 1, ... "device_type": 1, ... "status": 1 ... }, ... { ... "name": "test1-core4", ... "device_role": 3, ... "site": 1, ... "device_type": 1, ... "status": 1 ... } ... ]) """ req = Request( base=self.url, token=self.token, session_key=self.session_key, http_session=self.api.http_session, ).post(args[0] if args else kwargs) if isinstance(req, list): return [self.return_obj(i, self.api, self) for i in req] return self.return_obj(req, self.api, self) def update(self, objects): r"""Bulk updates existing objects on an endpoint. Allows for bulk updating of existing objects on an endpoint. Objects is a list whic contain either json/dicts or Record derived objects, which contain the updates to apply. If json/dicts are used, then the id of the object *must* be included :arg list objects: A list of dicts or Record. :returns: True if the update succeeded :Examples: Updating objects on the `devices` endpoint: >>> devices = nb.dcim.devices.update([ ... {'id': 1, 'name': 'test'}, ... {'id': 2, 'name': 'test2'}, ... ]) >>> devices [test2, test] >>> Use bulk update by passing a list of Records: >>> devices = list(nb.dcim.devices.filter()) >>> devices [Device1, Device2, Device3] >>> for d in devices: ... d.name = d.name+'-test' ... >>> nb.dcim.devices.update(devices) [Device1-test, Device2-test, Device3-test] >>> """ series = [] if not isinstance(objects, list): raise ValueError( "Objects passed must be list[dict|Record] - was " + type(objects) ) for o in objects: if isinstance(o, Record): data = o.updates() if data: data["id"] = o.id series.append(data) elif isinstance(o, dict): if "id" not in o: raise ValueError("id is missing from object: " + str(o)) series.append(o) else: raise ValueError( "Object passed must be dict|Record - was " + type(objects) ) req = Request( base=self.url, token=self.token, session_key=self.session_key, http_session=self.api.http_session, ).patch(series) if isinstance(req, list): return [self.return_obj(i, self.api, self) for i in req] return self.return_obj(req, self.api, self) def delete(self, objects): r"""Bulk deletes objects on an endpoint. Allows for batch deletion of multiple objects from a single endpoint :arg list objects: A list of either ids or Records or a single RecordSet to delete. :returns: True if bulk DELETE operation was successful. :Examples: Deleting all `devices`: >>> netbox.dcim.devices.delete(netbox.dcim.devices.all(0)) >>> Use bulk deletion by passing a list of ids: >>> netbox.dcim.devices.delete([2, 243, 431, 700]) >>> Use bulk deletion to delete objects eg. when filtering on a `custom_field`: >>> netbox.dcim.devices.delete([ >>> d for d in netbox.dcim.devices.all(0) \ >>> if d.custom_fields.get('field', False) >>> ]) >>> """ cleaned_ids = [] if not isinstance(objects, list) and not isinstance(objects, RecordSet): raise ValueError( "objects must be list[str|int|Record]" "|RecordSet - was " + str(type(objects)) ) for o in objects: if isinstance(o, int): cleaned_ids.append(o) elif isinstance(o, str) and o.isnumeric(): cleaned_ids.append(int(o)) elif isinstance(o, Record): if not hasattr(o, "id"): raise ValueError( "Record from '" + o.url + "' does not have an id and cannot be bulk deleted" ) cleaned_ids.append(o.id) else: raise ValueError( "Invalid object in list of objects to delete: " + str(type(o)) ) req = Request( base=self.url, token=self.token, session_key=self.session_key, http_session=self.api.http_session, ) return True if req.delete(data=[{"id": i} for i in cleaned_ids]) else False def choices(self): """Returns all choices from the endpoint. The returned dict is also saved in the endpoint object (in ``_choices`` attribute) so that later calls will return the same data without recurring requests to NetBox. When using ``.choices()`` in long-running applications, consider restarting them whenever NetBox is upgraded, to prevent using stale choices data. :Returns: Dict containing the available choices. :Example (from NetBox 2.8.x): >>> from pprint import pprint >>> pprint(nb.ipam.ip_addresses.choices()) {'role': [{'display_name': 'Loopback', 'value': 'loopback'}, {'display_name': 'Secondary', 'value': 'secondary'}, {'display_name': 'Anycast', 'value': 'anycast'}, {'display_name': 'VIP', 'value': 'vip'}, {'display_name': 'VRRP', 'value': 'vrrp'}, {'display_name': 'HSRP', 'value': 'hsrp'}, {'display_name': 'GLBP', 'value': 'glbp'}, {'display_name': 'CARP', 'value': 'carp'}], 'status': [{'display_name': 'Active', 'value': 'active'}, {'display_name': 'Reserved', 'value': 'reserved'}, {'display_name': 'Deprecated', 'value': 'deprecated'}, {'display_name': 'DHCP', 'value': 'dhcp'}]} >>> """ if self._choices: return self._choices req = Request( base=self.url, token=self.api.token, private_key=self.api.private_key, http_session=self.api.http_session, ).options() try: post_data = req["actions"]["POST"] except KeyError: raise ValueError( "Unexpected format in the OPTIONS response at {}".format(self.url) ) self._choices = {} for prop in post_data: if "choices" in post_data[prop]: self._choices[prop] = post_data[prop]["choices"] return self._choices def count(self, *args, **kwargs): r"""Returns the count of objects in a query. Takes named arguments that match the usable filters on a given endpoint. If an argument is passed then it's used as a freeform search argument if the endpoint supports it. If no arguments are passed the count for all objects on an endpoint are returned. :arg str,optional \*args: Freeform search string that's accepted on given endpoint. :arg str,optional \**kwargs: Any search argument the endpoint accepts can be added as a keyword arg. :Returns: Integer with count of objects returns by query. :Examples: To return a count of objects matching a named argument filter. >>> nb.dcim.devices.count(site='tst1') 5827 >>> To return a count of objects on an entire endpoint. >>> nb.dcim.devices.count() 87382 >>> """ if args: kwargs.update({"q": args[0]}) if any(i in RESERVED_KWARGS for i in kwargs): raise ValueError( "A reserved {} kwarg was passed. Please remove it " "try again.".format(RESERVED_KWARGS) ) ret = Request( filters=kwargs, base=self.url, token=self.token, session_key=self.session_key, http_session=self.api.http_session, ) return ret.get_count() class DetailEndpoint: """Enables read/write operations on detail endpoints. Endpoints like ``available-ips`` that are detail routes off traditional endpoints are handled with this class. """ def __init__(self, parent_obj, name, custom_return=None): self.parent_obj = parent_obj self.custom_return = custom_return self.url = "{}/{}/{}/".format(parent_obj.endpoint.url, parent_obj.id, name) self.request_kwargs = dict( base=self.url, token=parent_obj.api.token, session_key=parent_obj.api.session_key, http_session=parent_obj.api.http_session, ) def list(self, **kwargs): r"""The view operation for a detail endpoint Returns the response from NetBox for a detail endpoint. :args \**kwargs: key/value pairs that get converted into url parameters when passed to the endpoint. E.g. ``.list(method='get_facts')`` would be converted to ``.../?method=get_facts``. :returns: A :py:class:`.Record` object or list of :py:class:`.Record` objects created from data retrieved from NetBox. """ req = Request(**self.request_kwargs).get(add_params=kwargs) if self.custom_return: return [ self.custom_return( i, self.parent_obj.endpoint.api, self.parent_obj.endpoint ) for i in req ] return req def create(self, data=None): """The write operation for a detail endpoint. Creates objects on a detail endpoint in NetBox. :arg dict/list,optional data: A dictionary containing the key/value pair of the items you're creating on the parent object. Defaults to empty dict which will create a single item with default values. :returns: A :py:class:`.Record` object or list of :py:class:`.Record` objects created from data created in NetBox. """ data = data or {} req = Request(**self.request_kwargs).post(data) if self.custom_return: if isinstance(req, list): return [ self.custom_return( req_item, self.parent_obj.endpoint.api, self.parent_obj.endpoint ) for req_item in req ] else: return self.custom_return( req, self.parent_obj.endpoint.api, self.parent_obj.endpoint ) return req class RODetailEndpoint(DetailEndpoint): def create(self, data): raise NotImplementedError("Writes are not supported for this endpoint.") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/core/query.py0000644000175100001730000003601614344673022017321 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import concurrent.futures as cf import json from urllib.parse import urlencode def calc_pages(limit, count): """Calculate number of pages required for full results set.""" return int(count / limit) + (limit % count > 0) class RequestError(Exception): """Basic Request Exception More detailed exception that returns the original requests object for inspection. Along with some attributes with specific details from the requests object. If return is json we decode and add it to the message. :Example: >>> try: ... nb.dcim.devices.create(name="destined-for-failure") ... except pynetbox.RequestError as e: ... print(e.error) """ def __init__(self, req): if req.status_code == 404: self.message = "The requested url: {} could not be found.".format(req.url) else: try: self.message = "The request failed with code {} {}: {}".format( req.status_code, req.reason, req.json() ) except ValueError: self.message = ( "The request failed with code {} {} but more specific " "details were not returned in json. Check the NetBox Logs " "or investigate this exception's error attribute.".format( req.status_code, req.reason ) ) super().__init__(self.message) self.req = req self.request_body = req.request.body self.base = req.url self.error = req.text def __str__(self): return self.message class AllocationError(Exception): """Allocation Exception Used with available-ips/available-prefixes when there is no room for allocation and NetBox returns 204 No Content (before NetBox 3.1.1) or 409 Conflict (since NetBox 3.1.1+). """ def __init__(self, req): super().__init__(req) self.req = req self.request_body = req.request.body self.base = req.url self.error = "The requested allocation could not be fulfilled." def __str__(self): return self.error class ContentError(Exception): """Content Exception If the API URL does not point to a valid NetBox API, the server may return a valid response code, but the content is not json. This exception is raised in those cases. """ def __init__(self, req): super().__init__(req) self.req = req self.request_body = req.request.body self.base = req.url self.error = ( "The server returned invalid (non-json) data. Maybe not a NetBox server?" ) def __str__(self): return self.error class Request: """Creates requests to the Netbox API Responsible for building the url and making the HTTP(S) requests to Netbox's API :param base: (str) Base URL passed in api() instantiation. :param filters: (dict, optional) contains key/value pairs that correlate to the filters a given endpoint accepts. In (e.g. /api/dcim/devices/?name='test') 'name': 'test' would be in the filters dict. :param private_key: (str, optional) The user's private key as a string. """ def __init__( self, base, http_session, filters=None, limit=None, offset=None, key=None, token=None, private_key=None, session_key=None, threading=False, ): """ Instantiates a new Request object Args: base (string): Base URL passed in api() instantiation. filters (dict, optional): contains key/value pairs that correlate to the filters a given endpoint accepts. In (e.g. /api/dcim/devices/?name='test') 'name': 'test' would be in the filters dict. key (int, optional): database id of the item being queried. private_key (string, optional): The user's private key as a string. """ self.base = self.normalize_url(base) self.filters = filters or None self.key = key self.token = token self.private_key = private_key self.session_key = session_key self.http_session = http_session self.url = self.base if not key else "{}{}/".format(self.base, key) self.threading = threading self.limit = limit self.offset = offset def get_openapi(self): """Gets the OpenAPI Spec""" headers = { "Content-Type": "application/json;", } req = self.http_session.get( "{}docs/?format=openapi".format(self.normalize_url(self.base)), headers=headers, ) if req.ok: return req.json() else: raise RequestError(req) def get_version(self): """Gets the API version of NetBox. Issues a GET request to the base URL to read the API version from the response headers. :Raises: RequestError if req.ok returns false. :Returns: Version number as a string. Empty string if version is not present in the headers. """ headers = { "Content-Type": "application/json;", } req = self.http_session.get( self.normalize_url(self.base), headers=headers, ) if req.ok: return req.headers.get("API-Version", "") else: raise RequestError(req) def get_session_key(self): """Requests session key Issues a GET request to the `get-session-key` endpoint for subsequent use in requests from the `secrets` endpoint. :Returns: String containing session key. """ req = self.http_session.post( "{}secrets/get-session-key/?preserve_key=True".format(self.base), headers={ "accept": "application/json", "authorization": "Token {}".format(self.token), "Content-Type": "application/x-www-form-urlencoded", }, data=urlencode({"private_key": self.private_key.strip("\n")}), ) if req.ok: try: return req.json()["session_key"] except json.JSONDecodeError: raise ContentError(req) else: raise RequestError(req) def get_status(self): """Gets the status from /api/status/ endpoint in NetBox. :Returns: Dictionary as returned by NetBox. :Raises: RequestError if request is not successful. """ headers = {"Content-Type": "application/json;"} if self.token: headers["authorization"] = "Token {}".format(self.token) req = self.http_session.get( "{}status/".format(self.normalize_url(self.base)), headers=headers, ) if req.ok: return req.json() else: raise RequestError(req) def normalize_url(self, url): """Builds a url for POST actions.""" if url[-1] != "/": return "{}/".format(url) return url def _make_call(self, verb="get", url_override=None, add_params=None, data=None): if verb in ("post", "put") or verb == "delete" and data: headers = {"Content-Type": "application/json;"} else: headers = {"accept": "application/json;"} if self.token: headers["authorization"] = "Token {}".format(self.token) if self.session_key: headers["X-Session-Key"] = self.session_key params = {} if not url_override: if self.filters: params.update(self.filters) if add_params: params.update(add_params) req = getattr(self.http_session, verb)( url_override or self.url, headers=headers, params=params, json=data ) if req.status_code in [204, 409] and verb == "post": raise AllocationError(req) if verb == "delete": if req.ok: return True else: raise RequestError(req) elif req.ok: try: return req.json() except json.JSONDecodeError: raise ContentError(req) else: raise RequestError(req) def concurrent_get(self, ret, page_size, page_offsets): futures_to_results = [] with cf.ThreadPoolExecutor(max_workers=4) as pool: for offset in page_offsets: new_params = {"offset": offset, "limit": page_size} futures_to_results.append( pool.submit(self._make_call, add_params=new_params) ) for future in cf.as_completed(futures_to_results): result = future.result() ret.extend(result["results"]) def get(self, add_params=None): """Makes a GET request. Makes a GET request to NetBox's API, and automatically recurses any paginated results. :raises: RequestError if req.ok returns false. :raises: ContentError if response is not json. :Returns: List of `Response` objects returned from the endpoint. """ if not add_params and self.limit is not None: add_params = {"limit": self.limit} if self.limit and self.offset is not None: # if non-zero limit and some offset -> add offset add_params["offset"] = self.offset req = self._make_call(add_params=add_params) if isinstance(req, dict) and req.get("results") is not None: self.count = req["count"] if self.offset is not None: # only yield requested page results if paginating for i in req["results"]: yield i elif self.threading: ret = req["results"] if req.get("next"): page_size = len(req["results"]) pages = calc_pages(page_size, req["count"]) page_offsets = [ increment * page_size for increment in range(1, pages) ] if pages == 1: req = self._make_call(url_override=req.get("next")) ret.extend(req["results"]) else: self.concurrent_get(ret, page_size, page_offsets) for i in ret: yield i else: first_run = True for i in req["results"]: yield i while req["next"]: # Not worrying about making sure add_params kwargs is # passed in here because results from detail routes aren't # paginated, thus far. if first_run: req = self._make_call( add_params={ "limit": self.limit or req["count"], "offset": len(req["results"]), } ) else: req = self._make_call(url_override=req["next"]) first_run = False for i in req["results"]: yield i elif isinstance(req, list): self.count = len(req) for i in req: yield i else: self.count = len(req) yield req def put(self, data): """Makes PUT request. Makes a PUT request to NetBox's API. Adds the session key to headers if the `private_key` attribute was populated. :param data: (dict) Contains a dict that will be turned into a json object and sent to the API. :raises: RequestError if req.ok returns false. :raises: ContentError if response is not json. :returns: Dict containing the response from NetBox's API. """ return self._make_call(verb="put", data=data) def post(self, data): """Makes POST request. Makes a POST request to NetBox's API. Adds the session key to headers if the `private_key` attribute was populated. :param data: (dict) Contains a dict that will be turned into a json object and sent to the API. :raises: RequestError if req.ok returns false. :raises: AllocationError if req.status_code is 204 (No Content) as with available-ips and available-prefixes when there is no room for the requested allocation. :raises: ContentError if response is not json. :Returns: Dict containing the response from NetBox's API. """ return self._make_call(verb="post", data=data) def delete(self, data=None): """Makes DELETE request. Makes a DELETE request to NetBox's API. :param data: (list) Contains a dict that will be turned into a json object and sent to the API. Returns: True if successful. Raises: RequestError if req.ok doesn't return True. """ return self._make_call(verb="delete", data=data) def patch(self, data): """Makes PATCH request. Makes a PATCH request to NetBox's API. :param data: (dict) Contains a dict that will be turned into a json object and sent to the API. :raises: RequestError if req.ok returns false. :raises: ContentError if response is not json. :returns: Dict containing the response from NetBox's API. """ return self._make_call(verb="patch", data=data) def options(self): """Makes an OPTIONS request. Makes an OPTIONS request to NetBox's API. :raises: RequestError if req.ok returns false. :raises: ContentError if response is not json. :returns: Dict containing the response from NetBox's API. """ return self._make_call(verb="options") def get_count(self, *args, **kwargs): """Returns object count for query Makes a query to the endpoint with ``limit=1`` set and only returns the value of the "count" field. :raises: RequestError if req.ok returns false. :raises: ContentError if response is not json. :returns: Int of number of objects query returned. """ if not hasattr(self, "count"): self.count = self._make_call(add_params={"limit": 1})["count"] return self.count ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/core/response.py0000644000175100001730000004470214344673022020013 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import copy from collections import OrderedDict 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") def get_return(lookup, return_fields=None): """Returns simple representations for items passed to lookup. Used to return a "simple" representation of objects and collections sent to it via lookup. Otherwise, we look to see if lookup is a "choices" field (dict with only 'id' and 'value') or a nested_return. Finally, we check if it's a Record, if so simply return a string. Order is important due to nested_return being self-referential. :arg list,optional return_fields: A list of fields to reference when calling values on lookup. """ for i in return_fields or ["id", "value", "nested_return"]: if isinstance(lookup, dict) and lookup.get(i): return lookup[i] else: if hasattr(lookup, i): # check if this is a "choices" field record # from a NetBox 2.7 server. if sorted(dict(lookup)) == sorted(["id", "value", "label"]): return getattr(lookup, "value") return getattr(lookup, i) if isinstance(lookup, Record): return str(lookup) else: return lookup def flatten_custom(custom_dict): return { k: v if not isinstance(v, dict) else v["value"] for k, v in custom_dict.items() } class JsonField: """Explicit field type for values that are not to be converted to a Record object""" _json_field = True class RecordSet: """Iterator containing Record objects. Returned by :py:meth:`.Endpoint.all()` and :py:meth:`.Endpoint.filter()` methods. Allows iteration of and actions to be taken on the results from the aforementioned methods. Contains :py:class:`.Record` objects. :Examples: To see how many results are in a query by calling ``len()``: >>> x = nb.dcim.devices.all() >>> len(x) 123 >>> Simple iteration of the results: >>> devices = nb.dcim.devices.all() >>> for device in devices: ... print(device.name) ... test1-leaf1 test1-leaf2 test1-leaf3 >>> """ def __init__(self, endpoint, request, **kwargs): self.endpoint = endpoint self.request = request self.response = self.request.get() self._response_cache = [] def __iter__(self): return self def __next__(self): if self._response_cache: return self.endpoint.return_obj( self._response_cache.pop(), self.endpoint.api, self.endpoint ) return self.endpoint.return_obj( next(self.response), self.endpoint.api, self.endpoint ) def __len__(self): try: return self.request.count except AttributeError: try: self._response_cache.append(next(self.response)) except StopIteration: return 0 return self.request.count def update(self, **kwargs): """Updates kwargs onto all Records in the RecordSet and saves these. Updates are only sent to the API if a value were changed, and only for the Records which were changed :returns: True if the update succeeded, None if no update were required :example: >>> result = nb.dcim.devices.filter(site_id=1).update(status='active') True >>> """ updates = [] for record in self: # Update each record and determine if anything was updated for k, v in kwargs.items(): setattr(record, k, v) record_updates = record.updates() if record_updates: # if updated, add the id to the dict and append to list of updates record_updates["id"] = record.id updates.append(record_updates) if updates: return self.endpoint.update(updates) else: return None def delete(self): r"""Bulk deletes objects in a RecordSet. Allows for batch deletion of multiple objects in a RecordSet :returns: True if bulk DELETE operation was successful. :Examples: Deleting offline `devices` on site 1: >>> netbox.dcim.devices.filter(site_id=1, status="offline").delete() >>> """ return self.endpoint.delete(self) class Record: """Create Python objects from NetBox API responses. Creates an object from a NetBox response passed as ``values``. Nested dicts that represent other endpoints are also turned into ``Record`` objects. All fields are then assigned to the object's attributes. If a missing attr is requested (e.g. requesting a field that's only present on a full response on a ``Record`` made from a nested response) then pynetbox will make a request for the full object and return the requested value. :examples: Default representation of the object is usually its name: >>> x = nb.dcim.devices.get(1) >>> x test1-switch1 >>> Querying a string field: >>> x = nb.dcim.devices.get(1) >>> x.serial 'ABC123' >>> Querying a field on a nested object: >>> x = nb.dcim.devices.get(1) >>> x.device_type.model 'QFX5100-24Q' >>> Casting the object as a dictionary: >>> from pprint import pprint >>> pprint(dict(x)) {'asset_tag': None, 'cluster': None, 'comments': '', 'config_context': {}, 'created': '2018-04-01', 'custom_fields': {}, 'device_role': {'id': 1, 'name': 'Test Switch', 'slug': 'test-switch', 'url': 'http://localhost:8000/api/dcim/device-roles/1/'}, 'device_type': {...}, 'display_name': 'test1-switch1', 'face': {'label': 'Rear', 'value': 1}, 'id': 1, 'name': 'test1-switch1', 'parent_device': None, 'platform': {...}, 'position': 1, 'primary_ip': {'address': '192.0.2.1/24', 'family': 4, 'id': 1, 'url': 'http://localhost:8000/api/ipam/ip-addresses/1/'}, 'primary_ip4': {...}, 'primary_ip6': None, 'rack': {'display_name': 'Test Rack', 'id': 1, 'name': 'Test Rack', 'url': 'http://localhost:8000/api/dcim/racks/1/'}, 'serial': 'ABC123', 'site': {'id': 1, 'name': 'TEST', 'slug': 'TEST', 'url': 'http://localhost:8000/api/dcim/sites/1/'}, 'status': {'label': 'Active', 'value': 1}, 'tags': [], 'tenant': None, 'vc_position': None, 'vc_priority': None, 'virtual_chassis': None} >>> Iterating over a ``Record`` object: >>> for i in x: ... print(i) ... ('id', 1) ('name', 'test1-switch1') ('display_name', 'test1-switch1') >>> """ url = None def __init__(self, values, api, endpoint): self.has_details = False self._full_cache = [] self._init_cache = [] self.api = api self.default_ret = Record self.endpoint = ( self._endpoint_from_url(values["url"]) if values and "url" in values else endpoint ) if values: self._parse_values(values) def __getattr__(self, k): """Default behavior for missing attrs. We'll call `full_details()` if we're asked for an attribute we don't have. In order to prevent non-explicit behavior,`k='keys'` is excluded because casting to dict() calls this attr. """ if self.url: if self.has_details is False and k != "keys": if self.full_details(): ret = getattr(self, k, None) if ret or hasattr(self, k): return ret raise AttributeError('object has no attribute "{}"'.format(k)) def __iter__(self): for i in dict(self._init_cache): cur_attr = getattr(self, i) if isinstance(cur_attr, Record): yield i, dict(cur_attr) elif isinstance(cur_attr, list) and all( isinstance(i, Record) for i in cur_attr ): yield i, [dict(x) for x in cur_attr] else: yield i, cur_attr def __getitem__(self, k): return dict(self)[k] def __str__(self): return ( getattr(self, "name", None) or getattr(self, "label", None) or getattr(self, "display", None) or "" ) def __repr__(self): return str(self) def __getstate__(self): return self.__dict__ def __setstate__(self, d): self.__dict__.update(d) def __key__(self): if hasattr(self, "id"): return (self.endpoint.name, self.id) else: return self.endpoint.name def __hash__(self): return hash(self.__key__()) def __eq__(self, other): if isinstance(other, Record): return self.__key__() == other.__key__() return NotImplemented def _add_cache(self, item): key, value = item self._init_cache.append((key, get_return(value))) def _parse_values(self, values): """Parses values init arg. Parses values dict at init and sets object attributes with the values within. """ def generic_list_parser(key_name, list_item): from pynetbox.models.mapper import CONTENT_TYPE_MAPPER if ( isinstance(list_item, dict) and "object_type" in list_item and "object" in list_item ): lookup = list_item["object_type"] model = None model = CONTENT_TYPE_MAPPER.get(lookup) if model: return model(list_item["object"], self.api, self.endpoint) return list_item def list_parser(key_name, list_item): if isinstance(list_item, dict): lookup = getattr(self.__class__, key_name, None) if not isinstance(lookup, list): # This is *list_parser*, so if the custom model field is not # a list (or is not defined), just return the default model return self.default_ret(list_item, self.api, self.endpoint) else: model = lookup[0] return model(list_item, self.api, self.endpoint) return list_item for k, v in values.items(): if isinstance(v, dict): lookup = getattr(self.__class__, k, None) if k in ["custom_fields", "local_context_data"] or hasattr( lookup, "_json_field" ): self._add_cache((k, copy.deepcopy(v))) setattr(self, k, v) continue if lookup: v = lookup(v, self.api, self.endpoint) else: v = self.default_ret(v, self.api, self.endpoint) self._add_cache((k, v)) elif isinstance(v, list): # check if GFK if len(v) and isinstance(v[0], dict) and "object_type" in v[0]: v = [generic_list_parser(k, i) for i in v] to_cache = list(v) else: v = [list_parser(k, i) for i in v] to_cache = list(v) self._add_cache((k, to_cache)) else: self._add_cache((k, v)) setattr(self, k, v) def _endpoint_from_url(self, url): url_path = urlsplit(url).path base_url_path_parts = urlsplit(self.api.base_url).path.split("/") if len(base_url_path_parts) > 2: # There are some extra directories in the path, remove them from url extra_path = "/".join(base_url_path_parts[:-1]) url_path = url_path[len(extra_path) :] split_url_path = url_path.split("/") if split_url_path[2] == "plugins": app = "plugins/{}".format(split_url_path[3]) name = split_url_path[4] else: app, name = split_url_path[2:4] return getattr(pynetbox.core.app.App(self.api, app), name) def full_details(self): """Queries the hyperlinked endpoint if 'url' is defined. This method will populate the attributes from the detail endpoint when it's called. Sets the class-level `has_details` attribute when it's called to prevent being called more than once. :returns: True """ if self.url: req = Request( base=self.url, token=self.api.token, session_key=self.api.session_key, http_session=self.api.http_session, ) self._parse_values(next(req.get())) self.has_details = True return True return False def serialize(self, nested=False, init=False): """Serializes an object Pulls all the attributes in an object and creates a dict that can be turned into the json that netbox is expecting. If an attribute's value is a ``Record`` type it's replaced with the ``id`` field of that object. .. note:: Using this to get a dictionary representation of the record is discouraged. It's probably better to cast to dict() instead. See Record docstring for example. :returns: dict. """ if nested: return get_return(self) if init: init_vals = dict(self._init_cache) ret = {} for i in dict(self): current_val = getattr(self, i) if not init else init_vals.get(i) if i == "custom_fields": ret[i] = flatten_custom(current_val) else: if isinstance(current_val, Record): current_val = getattr(current_val, "serialize")(nested=True) if isinstance(current_val, list): current_val = [ v.id if isinstance(v, Record) else v for v in current_val ] if i in LIST_AS_SET and ( all([isinstance(v, str) for v in current_val]) or all([isinstance(v, int) for v in current_val]) ): current_val = list(OrderedDict.fromkeys(current_val)) ret[i] = current_val return ret def _diff(self): def fmt_dict(k, v): if isinstance(v, dict): return k, Hashabledict(v) if isinstance(v, list): return k, ",".join(map(str, v)) return k, v current = Hashabledict({fmt_dict(k, v) for k, v in self.serialize().items()}) init = Hashabledict( {fmt_dict(k, v) for k, v in self.serialize(init=True).items()} ) return set([i[0] for i in set(current.items()) ^ set(init.items())]) def updates(self): """Compiles changes for an existing object into a dict. Takes a diff between the objects current state and its state at init and returns them as a dictionary, which will be empty if no changes. :returns: dict. :example: >>> x = nb.dcim.devices.get(name='test1-a3-tor1b') >>> x.serial '' >>> x.serial = '1234' >>> x.updates() {'serial': '1234'} >>> """ if self.id: diff = self._diff() if diff: serialized = self.serialize() return {i: serialized[i] for i in diff} return {} def save(self): """Saves changes to an existing object. Takes a diff between the objects current state and its state at init and sends them as a dictionary to Request.patch(). :returns: True if PATCH request was successful. :example: >>> x = nb.dcim.devices.get(name='test1-a3-tor1b') >>> x.serial '' >>> x.serial = '1234' >>> x.save() True >>> """ updates = self.updates() if updates: req = Request( key=self.id, base=self.endpoint.url, token=self.api.token, session_key=self.api.session_key, http_session=self.api.http_session, ) if req.patch(updates): return True return False def update(self, data): """Update an object with a dictionary. Accepts a dict and uses it to update the record and call save(). For nested and choice fields you'd pass an int the same as if you were modifying the attribute and calling save(). :arg dict data: Dictionary containing the k/v to update the record object with. :returns: True if PATCH request was successful. :example: >>> x = nb.dcim.devices.get(1) >>> x.update({ ... "name": "test-switch2", ... "serial": "ABC321", ... }) True """ for k, v in data.items(): setattr(self, k, v) return self.save() def delete(self): """Deletes an existing object. :returns: True if DELETE operation was successful. :example: >>> x = nb.dcim.devices.get(name='test1-a3-tor1b') >>> x.delete() True >>> """ req = Request( key=self.id, base=self.endpoint.url, token=self.api.token, session_key=self.api.session_key, http_session=self.api.http_session, ) return True if req.delete() else False ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/core/util.py0000644000175100001730000000012714344673022017123 0ustar00runnerdockerclass Hashabledict(dict): def __hash__(self): return hash(frozenset(self)) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2144508 pynetbox-7.0.0/pynetbox/models/0000755000175100001730000000000014344673035016133 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/models/__init__.py0000644000175100001730000000000014344673022020226 0ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/models/circuits.py0000644000175100001730000000137014344673022020327 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from pynetbox.core.response import Record class Circuits(Record): def __str__(self): return self.cid class CircuitTerminations(Record): def __str__(self): return self.circuit.cid ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/models/dcim.py0000644000175100001730000001462514344673022017425 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from urllib.parse import urlsplit from pynetbox.core.query import Request from pynetbox.core.response import Record, JsonField from pynetbox.core.endpoint import RODetailEndpoint from pynetbox.models.ipam import IpAddresses from pynetbox.models.circuits import Circuits class TraceableRecord(Record): def _get_obj_class(self, url): uri_to_obj_class_map = { "dcim/cables": Cables, "dcim/front-ports": FrontPorts, "dcim/interfaces": Interfaces, "dcim/rear-ports": RearPorts, } # the url for this item will be something like: # https://netbox/api/dcim/rear-ports/12761/ # TODO: Move this to a more general function. app_endpoint = "/".join( urlsplit(url).path[len(urlsplit(self.api.base_url).path) :].split("/")[1:3] ) return uri_to_obj_class_map.get( app_endpoint, Record, ) def _build_termination_data(self, termination_list): terminations_data = [] for hop_item_data in termination_list: return_obj_class = self._get_obj_class(hop_item_data["url"]) terminations_data.append( return_obj_class(hop_item_data, self.endpoint.api, self.endpoint) ) return terminations_data def trace(self): req = Request( key=str(self.id) + "/trace", base=self.endpoint.url, token=self.api.token, session_key=self.api.session_key, http_session=self.api.http_session, ).get() ret = [] for (a_terminations_data, cable_data, b_terminations_data) in req: ret.append(self._build_termination_data(a_terminations_data)) if not cable_data: ret.append(cable_data) else: return_obj_class = self._get_obj_class(cable_data["url"]) ret.append( return_obj_class(cable_data, self.endpoint.api, self.endpoint) ) ret.append(self._build_termination_data(b_terminations_data)) return ret class DeviceTypes(Record): def __str__(self): return self.model class Devices(Record): """Devices Object Represents a device response from netbox. Attributes: primary_ip, ip4, ip6 (list): Tells __init__ in Record() to take the `primary_ip` field's value from the API response and return an initialized list of IpAddress objects device_type (obj): Tells __init__ in Record() to take the `device_type` field's value from the API response and return an initialized DeviceType object """ has_details = True device_type = DeviceTypes primary_ip = IpAddresses primary_ip4 = IpAddresses primary_ip6 = IpAddresses local_context_data = JsonField config_context = JsonField @property def napalm(self): """Represents the ``napalm`` detail endpoint. Returns a DetailEndpoint object that is the interface for viewing response from the napalm endpoint. :returns: :py:class:`.DetailEndpoint` :Examples: >>> device = nb.ipam.devices.get(123) >>> device.napalm.list(method='get_facts') {"get_facts": {"interface_list": ["ge-0/0/0"]}} """ return RODetailEndpoint(self, "napalm") class InterfaceConnections(Record): def __str__(self): return self.interface_a.name class InterfaceConnection(Record): def __str__(self): return self.interface.name class ConnectedEndpoint(Record): device = Devices class Interfaces(TraceableRecord): interface_connection = InterfaceConnection connected_endpoint = ConnectedEndpoint class PowerOutlets(TraceableRecord): device = Devices class PowerPorts(TraceableRecord): device = Devices class ConsolePorts(TraceableRecord): device = Devices class ConsoleServerPorts(TraceableRecord): device = Devices class RackReservations(Record): def __str__(self): return self.description class VirtualChassis(Record): master = Devices class RUs(Record): device = Devices class FrontPorts(TraceableRecord): device = Devices class RearPorts(TraceableRecord): device = Devices class Racks(Record): @property def units(self): """Represents the ``units`` detail endpoint. Returns a DetailEndpoint object that is the interface for viewing response from the units endpoint. :returns: :py:class:`.DetailEndpoint` :Examples: >>> rack = nb.dcim.racks.get(123) >>> rack.units.list() {"get_facts": {"interface_list": ["ge-0/0/0"]}} """ return RODetailEndpoint(self, "units", custom_return=RUs) @property def elevation(self): """Represents the ``elevation`` detail endpoint. Returns a DetailEndpoint object that is the interface for viewing response from the elevation endpoint updated in Netbox version 2.8. :returns: :py:class:`.DetailEndpoint` :Examples: >>> rack = nb.dcim.racks.get(123) >>> rack.elevation.list() {"get_facts": {"interface_list": ["ge-0/0/0"]}} """ return RODetailEndpoint(self, "elevation", custom_return=RUs) class Termination(Record): def __str__(self): # hacky check to see if we're a circuit termination to # avoid another call to NetBox because of a non-existent attr # in self.name if "circuit" in str(self.url): return self.circuit.cid return self.name device = Devices circuit = Circuits class Cables(Record): def __str__(self): if len(self.a_terminations) == 1 and len(self.b_terminations) == 1: return "{} <> {}".format(self.a_terminations[0], self.b_terminations[0]) return "Cable #{}".format(self.id) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/models/extras.py0000644000175100001730000000150414344673022020007 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from pynetbox.core.response import Record, JsonField class ConfigContexts(Record): data = JsonField class ObjectChanges(Record): object_data = JsonField postchange_data = JsonField prechange_data = JsonField def __str__(self): return self.request_id ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/models/ipam.py0000644000175100001730000001120014344673022017421 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from pynetbox.core.response import Record from pynetbox.core.endpoint import DetailEndpoint class IpAddresses(Record): def __str__(self): return str(self.address) class IpRanges(Record): def __str__(self): return str(self.display) @property def available_ips(self): """Represents the ``available-ips`` detail endpoint. Returns a DetailEndpoint object that is the interface for viewing and creating IP addresses inside an ip range . :returns: :py:class:`.DetailEndpoint` :Examples: >>> ip_range = nb.ipam.ip_ranges.get(24) >>> ip_range.available_ips.list() [10.0.0.1/24, 10.0.0.2/24, 10.0.0.3/24, 10.0.0.4/24, 10.0.0.5/24, ...] To create a single IP: >>> ip_range = nb.ipam.ip_ranges.get(24) >>> ip_range.available_ips.create() 10.0.0.1/24 To create multiple IPs: >>> ip_range = nb.ipam.ip_ranges.get(24) >>> create = ip_range.available_ips.create([{} for i in range(2)]) >>> create [10.0.0.2/24, 10.0.0.3/24] """ return DetailEndpoint(self, "available-ips", custom_return=IpAddresses) class Prefixes(Record): def __str__(self): return str(self.prefix) @property def available_ips(self): """Represents the ``available-ips`` detail endpoint. Returns a DetailEndpoint object that is the interface for viewing and creating IP addresses inside a prefix. :returns: :py:class:`.DetailEndpoint` :Examples: >>> prefix = nb.ipam.prefixes.get(24) >>> prefix.available_ips.list() [10.0.0.1/24, 10.0.0.2/24, 10.0.0.3/24, 10.0.0.4/24, 10.0.0.5/24, ...] To create a single IP: >>> prefix = nb.ipam.prefixes.get(24) >>> prefix.available_ips.create() 10.0.0.1/24 To create multiple IPs: >>> prefix = nb.ipam.prefixes.get(24) >>> create = prefix.available_ips.create([{} for i in range(2)]) >>> create [10.0.0.2/24, 10.0.0.3/24] """ return DetailEndpoint(self, "available-ips", custom_return=IpAddresses) @property def available_prefixes(self): """Represents the ``available-prefixes`` detail endpoint. Returns a DetailEndpoint object that is the interface for viewing and creating prefixes inside a parent prefix. Very similar to :py:meth:`~pynetbox.ipam.Prefixes.available_ips` , except that dict (or list of dicts) passed to ``.create()`` needs to have a ``prefix_length`` key/value specifed. :returns: :py:class:`.DetailEndpoint` :Examples: >>> prefix = nb.ipam.prefixes.get(3) >>> prefix 10.0.0.0/16 >>> prefix.available_prefixes.list() [10.0.1.0/24, 10.0.2.0/23, 10.0.4.0/22, 10.0.8.0/21, 10.0.16.0/20, 10.0.32.0/19, 10.0.64.0/18, 10.0.128.0/17] Creating a single child prefix: >>> prefix = nb.ipam.prefixes.get(1) >>> prefix 10.0.0.0/24 >>> new_prefix = prefix.available_prefixes.create( ... {"prefix_length": 29} ... ) >>> new_prefix 10.0.0.16/29 """ return DetailEndpoint(self, "available-prefixes", custom_return=Prefixes) class Aggregates(Record): def __str__(self): return str(self.prefix) class Vlans(Record): def __str__(self): return super().__str__() or str(self.vid) class VlanGroups(Record): @property def available_vlans(self): """Represents the ``available-vlans`` detail endpoint. Returns a DetailEndpoint object that is the interface for viewing and creating VLANs inside a VLAN group. Available since NetBox 3.2.0. :returns: :py:class:`.DetailEndpoint` :Examples: >>> vlan_group = nb.ipam.vlan_groups.get(1) >>> vlan_group.available_vlans.list() [10, 11, 12] To create a new VLAN: >>> vlan_group.available_vlans.create({"name": "NewVLAN"}) NewVLAN (10) """ return DetailEndpoint(self, "available-vlans", custom_return=Vlans) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/models/mapper.py0000644000175100001730000000651714344673022017776 0ustar00runnerdockerfrom .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 .virtualization import VirtualMachines from .wireless import WirelessLans CONTENT_TYPE_MAPPER = { "circuits.circuit": Circuits, "circuits.circuittermination": CircuitTerminations, "dcim.cable": Cables, "dcim.cablepath": None, "dcim.cabletermination": Termination, "dcim.consoleport": ConsolePorts, "dcim.consoleporttemplate": None, "dcim.consoleserverport": ConsoleServerPorts, "dcim.consoleserverporttemplate": None, "dcim.device": Devices, "dcim.devicebay": None, "dcim.devicebaytemplate": None, "dcim.devicerole": None, "dcim.devicetype": DeviceTypes, "dcim.frontport": FrontPorts, "dcim.frontporttemplate": None, "dcim.interface": Interfaces, "dcim.interfacetemplate": None, "dcim.inventoryitem": None, "dcim.inventoryitemrole": None, "dcim.inventoryitemtemplate": None, "dcim.location": None, "dcim.manufacturer": None, "dcim.module": None, "dcim.modulebay": None, "dcim.modulebaytemplate": None, "dcim.moduletype": None, "dcim.platform": None, "dcim.powerfeed": None, "dcim.poweroutlet": PowerOutlets, "dcim.poweroutlettemplate": None, "dcim.powerpanel": None, "dcim.powerport": ConsolePorts, "dcim.powerporttemplate": None, "dcim.rack": Racks, "dcim.rackreservation": RackReservations, "dcim.rackrole": None, "dcim.rearport": RearPorts, "dcim.rearporttemplate": None, "dcim.region": None, "dcim.site": None, "dcim.sitegroup": None, "dcim.virtualchassis": VirtualChassis, "extras.configcontext": None, "extras.configrevision": None, "extras.customfield": None, "extras.customlink": None, "extras.exporttemplate": None, "extras.imageattachment": None, "extras.jobresult": None, "extras.journalentry": None, "extras.objectchange": None, "extras.report": None, "extras.script": None, "extras.tag": None, "extras.taggeditem": None, "extras.webhook": None, "ipam.aggregate": Aggregates, "ipam.ASN": None, "ipam.FHRPgroup": None, "ipam.FHRPgroupassignment": None, "ipam.IPaddress": IpAddresses, "ipam.IPrange": None, "ipam.L2VPN": None, "ipam.L2VPNtermination": None, "ipam.prefix": Prefixes, "ipam.RIR": None, "ipam.role": None, "ipam.routetarget": None, "ipam.service": None, "ipam.servicetemplate": None, "ipam.VLAN": Vlans, "ipam.VLANgroup": VlanGroups, "ipam.VRF": None, "tenancy.contact": None, "tenancy.contactassignment": None, "tenancy.contactgroup": None, "tenancy.contactrole": None, "tenancy.tenant": None, "tenancy.tenantgroup": None, "virtualization.cluster": None, "virtualization.clustergroup": None, "virtualization.clustertype": None, "virtualization.interface": None, "virtualization.virtualmachine": VirtualMachines, "wireless.WirelessLAN": WirelessLans, "wireless.WirelessLANGroup": None, "wireless.wirelesslink": None, } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/models/users.py0000644000175100001730000000136614344673022017650 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from pynetbox.core.response import Record, JsonField class Users(Record): def __str__(self): return self.username class Permissions(Record): users = [Users] constraints = JsonField ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/models/virtualization.py0000644000175100001730000000144514344673022021571 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from pynetbox.core.response import Record, JsonField from pynetbox.models.ipam import IpAddresses class VirtualMachines(Record): primary_ip = IpAddresses primary_ip4 = IpAddresses primary_ip6 = IpAddresses config_context = JsonField ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/pynetbox/models/wireless.py0000644000175100001730000000124114344673022020334 0ustar00runnerdocker""" (c) 2017 DigitalOcean Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from pynetbox.core.response import Record class WirelessLans(Record): def __str__(self): return self.ssid ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2144508 pynetbox-7.0.0/pynetbox.egg-info/0000755000175100001730000000000014344673035016342 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608413.0 pynetbox-7.0.0/pynetbox.egg-info/PKG-INFO0000644000175100001730000000103614344673035017437 0ustar00runnerdockerMetadata-Version: 2.1 Name: pynetbox Version: 7.0.0 Summary: NetBox API client library Home-page: https://github.com/netbox-community/netbox Author: Zach Moody Author-email: zmoody@do.co License: Apache2 Keywords: netbox Classifier: Intended Audience :: Developers Classifier: Development Status :: 5 - Production/Stable Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 License-File: LICENSE ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608413.0 pynetbox-7.0.0/pynetbox.egg-info/SOURCES.txt0000644000175100001730000001333414344673035020232 0ustar00runnerdocker.gitignore CHANGELOG.md LICENSE README.md requirements-dev.txt requirements.txt setup.py .github/workflows/publish.yml .github/workflows/py3.yml docs/IPAM.rst docs/Makefile docs/advanced.rst docs/conf.py docs/endpoint.rst docs/index.rst docs/request.rst docs/response.rst pynetbox/__init__.py pynetbox.egg-info/PKG-INFO pynetbox.egg-info/SOURCES.txt pynetbox.egg-info/dependency_links.txt pynetbox.egg-info/not-zip-safe pynetbox.egg-info/requires.txt pynetbox.egg-info/top_level.txt pynetbox/core/__init__.py pynetbox/core/api.py pynetbox/core/app.py pynetbox/core/endpoint.py pynetbox/core/query.py pynetbox/core/response.py pynetbox/core/util.py pynetbox/models/__init__.py pynetbox/models/circuits.py pynetbox/models/dcim.py pynetbox/models/extras.py pynetbox/models/ipam.py pynetbox/models/mapper.py pynetbox/models/users.py pynetbox/models/virtualization.py pynetbox/models/wireless.py tests/__init__.py tests/conftest.py tests/test_api.py tests/test_app.py tests/test_circuits.py tests/test_tenancy.py tests/test_users.py tests/test_virtualization.py tests/test_wireless.py tests/util.py tests/fixtures/api/get_session_key.json tests/fixtures/api/token_provision.json tests/fixtures/circuits/circuit.json tests/fixtures/circuits/circuit_termination.json tests/fixtures/circuits/circuit_terminations.json tests/fixtures/circuits/circuit_type.json tests/fixtures/circuits/circuit_types.json tests/fixtures/circuits/circuits.json tests/fixtures/circuits/provider.json tests/fixtures/circuits/providers.json tests/fixtures/dcim/cable.json tests/fixtures/dcim/cables.json tests/fixtures/dcim/choices.json tests/fixtures/dcim/console_port.json tests/fixtures/dcim/console_port_template.json tests/fixtures/dcim/console_port_templates.json tests/fixtures/dcim/console_ports.json tests/fixtures/dcim/console_server_port.json tests/fixtures/dcim/console_server_port_template.json tests/fixtures/dcim/console_server_port_templates.json tests/fixtures/dcim/console_server_ports.json tests/fixtures/dcim/device.json tests/fixtures/dcim/device_bay.json tests/fixtures/dcim/device_bay_template.json tests/fixtures/dcim/device_bay_templates.json tests/fixtures/dcim/device_bays.json tests/fixtures/dcim/device_bulk_create.json tests/fixtures/dcim/device_role.json tests/fixtures/dcim/device_roles.json tests/fixtures/dcim/device_type.json tests/fixtures/dcim/device_types.json tests/fixtures/dcim/devices.json tests/fixtures/dcim/interface.json tests/fixtures/dcim/interface_connection.json tests/fixtures/dcim/interface_connections.json tests/fixtures/dcim/interface_template.json tests/fixtures/dcim/interface_templates.json tests/fixtures/dcim/interface_trace.json tests/fixtures/dcim/interfaces.json tests/fixtures/dcim/interfaces_1.json tests/fixtures/dcim/interfaces_2.json tests/fixtures/dcim/inventory_item.json tests/fixtures/dcim/inventory_items.json tests/fixtures/dcim/manufacturer.json tests/fixtures/dcim/manufacturers.json tests/fixtures/dcim/napalm.json tests/fixtures/dcim/platform.json tests/fixtures/dcim/platforms.json tests/fixtures/dcim/power_outlet.json tests/fixtures/dcim/power_outlet_template.json tests/fixtures/dcim/power_outlet_templates.json tests/fixtures/dcim/power_outlets.json tests/fixtures/dcim/power_port.json tests/fixtures/dcim/power_port_template.json tests/fixtures/dcim/power_port_templates.json tests/fixtures/dcim/power_ports.json tests/fixtures/dcim/rack.json tests/fixtures/dcim/rack_group.json tests/fixtures/dcim/rack_groups.json tests/fixtures/dcim/rack_reservation.json tests/fixtures/dcim/rack_reservations.json tests/fixtures/dcim/rack_role.json tests/fixtures/dcim/rack_roles.json tests/fixtures/dcim/rack_u.json tests/fixtures/dcim/racks.json tests/fixtures/dcim/region.json tests/fixtures/dcim/regions.json tests/fixtures/dcim/site.json tests/fixtures/dcim/sites.json tests/fixtures/dcim/virtual_chassis_device.json tests/fixtures/dcim/virtual_chassis_devices.json tests/fixtures/ipam/aggregate.json tests/fixtures/ipam/aggregates.json tests/fixtures/ipam/available-ips-post.json tests/fixtures/ipam/available-ips.json tests/fixtures/ipam/available-prefixes-post.json tests/fixtures/ipam/available-prefixes.json tests/fixtures/ipam/ip_address.json tests/fixtures/ipam/ip_addresses.json tests/fixtures/ipam/prefix.json tests/fixtures/ipam/prefixes.json tests/fixtures/ipam/rir.json tests/fixtures/ipam/rirs.json tests/fixtures/ipam/role.json tests/fixtures/ipam/roles.json tests/fixtures/ipam/vlan.json tests/fixtures/ipam/vlan_group.json tests/fixtures/ipam/vlan_groups.json tests/fixtures/ipam/vlans.json tests/fixtures/ipam/vrf.json tests/fixtures/ipam/vrfs.json tests/fixtures/tenancy/tenant.json tests/fixtures/tenancy/tenant_group.json tests/fixtures/tenancy/tenant_groups.json tests/fixtures/tenancy/tenants.json tests/fixtures/users/group.json tests/fixtures/users/groups.json tests/fixtures/users/permission.json tests/fixtures/users/permissions.json tests/fixtures/users/unknown_model.json tests/fixtures/users/user.json tests/fixtures/users/users.json tests/fixtures/virtualization/cluster.json tests/fixtures/virtualization/cluster_group.json tests/fixtures/virtualization/cluster_groups.json tests/fixtures/virtualization/cluster_type.json tests/fixtures/virtualization/cluster_types.json tests/fixtures/virtualization/clusters.json tests/fixtures/virtualization/interface.json tests/fixtures/virtualization/interfaces.json tests/fixtures/virtualization/virtual_machine.json tests/fixtures/virtualization/virtual_machines.json tests/fixtures/wireless/wireless_lan.json tests/fixtures/wireless/wireless_lans.json tests/integration/conftest.py tests/integration/test_dcim.py tests/integration/test_ipam.py tests/unit/__init__.py tests/unit/test_detailendpoint.py tests/unit/test_endpoint.py tests/unit/test_extras.py tests/unit/test_query.py tests/unit/test_request.py tests/unit/test_response.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608413.0 pynetbox-7.0.0/pynetbox.egg-info/dependency_links.txt0000644000175100001730000000000114344673035022410 0ustar00runnerdocker ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608413.0 pynetbox-7.0.0/pynetbox.egg-info/not-zip-safe0000644000175100001730000000000114344673035020570 0ustar00runnerdocker ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608413.0 pynetbox-7.0.0/pynetbox.egg-info/requires.txt0000644000175100001730000000002614344673035020740 0ustar00runnerdockerrequests<3.0,>=2.20.0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608413.0 pynetbox-7.0.0/pynetbox.egg-info/top_level.txt0000644000175100001730000000001114344673035021064 0ustar00runnerdockerpynetbox ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/requirements-dev.txt0000644000175100001730000000007414344673022017035 0ustar00runnerdockerblack~=22.10 pytest==7.1.* pytest-docker==1.0.* PyYAML==6.0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/requirements.txt0000644000175100001730000000002614344673022016256 0ustar00runnerdockerrequests>=2.20.0,<3.0 ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.226451 pynetbox-7.0.0/setup.cfg0000644000175100001730000000004614344673035014621 0ustar00runnerdocker[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/setup.py0000644000175100001730000000150314344673022014505 0ustar00runnerdockerfrom setuptools import setup, find_packages setup( name="pynetbox", description="NetBox API client library", url="https://github.com/netbox-community/netbox", author="Zach Moody", author_email="zmoody@do.co", license="Apache2", include_package_data=True, use_scm_version=True, setup_requires=["setuptools_scm"], packages=find_packages(exclude=["tests", "tests.*"]), install_requires=[ "requests>=2.20.0,<3.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", ], ) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2144508 pynetbox-7.0.0/tests/0000755000175100001730000000000014344673035014142 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/__init__.py0000644000175100001730000000000014344673022016235 0ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/conftest.py0000644000175100001730000000434314344673022016341 0ustar00runnerdockerfrom urllib import parse import pytest from packaging import version DEFAULT_NETBOX_VERSIONS = "3.3" def pytest_addoption(parser): """Hook on the pytest option parser setup. Add some extra options to the parser. """ parser.addoption( "--netbox-versions", action="store", default=DEFAULT_NETBOX_VERSIONS, help=( "The versions of netbox to run integration tests against, as a" " comma-separated list. Default: %s" % DEFAULT_NETBOX_VERSIONS ), ) parser.addoption( "--no-cleanup", dest="cleanup", action="store_false", help=( "Skip any cleanup steps after the pytest session finishes. Any containers" " created will be left running and the docker-compose files used to" " create them will be left on disk." ), ) parser.addoption( "--url-override", dest="url_override", action="store", help=( "Overrides the URL to run tests to. This allows for testing to the same" " containers for seperate runs." ), ) def pytest_configure(config): """Hook that runs after test collection is completed. Here we can modify items in the collected tests or parser args. """ # verify the netbox versions parse correctly and split them config.option.netbox_versions = [ version.Version(version_string) for version_string in config.option.netbox_versions.split(",") ] if "no:docker" in config.option.plugins and config.option.url_override: url_parse = parse.urlparse(config.option.url_override) class DockerServicesMock: def __init__(self, ports): self.ports = ports def wait_until_responsive(self, *args, **kwargs): return None def port_for(self, *args): return self.ports class Plugin: @pytest.fixture(scope="session") def docker_ip(self): return "127.0.0.1" @pytest.fixture(scope="session") def docker_services(self): return DockerServicesMock(url_parse.port) config.pluginmanager.register(Plugin()) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2104506 pynetbox-7.0.0/tests/fixtures/0000755000175100001730000000000014344673035016013 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2144508 pynetbox-7.0.0/tests/fixtures/api/0000755000175100001730000000000014344673035016564 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/api/get_session_key.json0000644000175100001730000000005414344673022022644 0ustar00runnerdocker{ "session_key": "ansodicnaoiwenafoi=" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/api/token_provision.json0000644000175100001730000000007214344673022022702 0ustar00runnerdocker{ "key": "1234567890123456789012345678901234567890" } ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1670608413.2144508 pynetbox-7.0.0/tests/fixtures/circuits/0000755000175100001730000000000014344673035017640 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/circuits/circuit.json0000644000175100001730000000075314344673022022176 0ustar00runnerdocker{ "id": 1, "cid": "123456", "provider": { "id": 1, "url": "http://localhost:8000/api/circuits/providers/1/", "name": "TEST", "slug": "test" }, "type": { "id": 1, "url": "http://localhost:8000/api/circuits/circuit-types/1/", "name": "Transit", "slug": "transit" }, "tenant": null, "install_date": null, "commit_rate": null, "description": "", "comments": "", "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/circuits/circuit_termination.json0000644000175100001730000000166014344673022024605 0ustar00runnerdocker{ "id": 1, "circuit": { "id": 1, "url": "http://localhost:8000/api/circuits/circuits/1/", "cid": "123456" }, "term_side": "A", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "interface": { "id": 4, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/0", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "TEST", "connection": null, "connected_interface": null }, "port_speed": 1000000, "upstream_speed": null, "xconnect_id": "", "pp_info": "" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/circuits/circuit_terminations.json0000644000175100001730000000247314344673022024773 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "circuit": { "id": 1, "url": "http://localhost:8000/api/circuits/circuits/1/", "cid": "123456" }, "term_side": "A", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "interface": { "id": 4, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/0", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "TEST", "connection": null, "connected_interface": null }, "port_speed": 1000000, "upstream_speed": null, "xconnect_id": "", "pp_info": "" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/circuits/circuit_type.json0000644000175100001730000000007514344673022023234 0ustar00runnerdocker{ "id": 1, "name": "Transit", "slug": "transit" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/circuits/circuit_types.json0000644000175100001730000000027014344673022023414 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "Transit", "slug": "transit" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/circuits/circuits.json0000644000175100001730000000135614344673022022361 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "cid": "123456", "provider": { "id": 1, "url": "http://localhost:8000/api/circuits/providers/1/", "name": "TEST", "slug": "test" }, "type": { "id": 1, "url": "http://localhost:8000/api/circuits/circuit-types/1/", "name": "Transit", "slug": "transit" }, "tenant": null, "install_date": null, "commit_rate": null, "description": "", "comments": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/circuits/provider.json0000644000175100001730000000031614344673022022361 0ustar00runnerdocker{ "id": 1, "name": "TEST", "slug": "test", "asn": null, "account": "", "portal_url": "", "noc_contact": "", "admin_contact": "", "comments": "", "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/circuits/providers.json0000644000175100001730000000060114344673022022541 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "TEST", "slug": "test", "asn": null, "account": "", "portal_url": "", "noc_contact": "", "admin_contact": "", "comments": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.222451 pynetbox-7.0.0/tests/fixtures/dcim/0000755000175100001730000000000014344673035016727 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/cable.json0000644000175100001730000000202614344673022020664 0ustar00runnerdocker{ "id": 1, "termination_a_type": "dcim.consoleport", "termination_a_id": 1, "termination_a": { "id": 1, "url": "http://localhost:8000/api/dcim/console-ports/1/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "tst1-test1", "display_name": "tst1-test1" }, "name": "Console", "cable": 1 }, "termination_b_type": "dcim.consoleserverport", "termination_b_id": 2, "termination_b": { "id": 2, "url": "http://localhost:8000/api/dcim/console-server-ports/2/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "tst1-test2", "display_name": "tst1-test2" }, "name": "Port 10", "cable": 1 }, "type": null, "status": { "value": true, "label": "Connected" }, "label": "", "color": "", "length": null, "length_unit": null }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/cables.json0000644000175100001730000001013014344673022021042 0ustar00runnerdocker{ "count": 3, "next": null, "previous": null, "results": [ { "id": 1, "termination_a_type": "dcim.consoleport", "termination_a_id": 1, "termination_a": { "id": 1, "url": "http://localhost:8000/api/dcim/console-ports/1/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "tst1-test1", "display_name": "tst1-test1" }, "name": "Console", "cable": 1 }, "termination_b_type": "dcim.consoleserverport", "termination_b_id": 2, "termination_b": { "id": 2, "url": "http://localhost:8000/api/dcim/console-server-ports/2/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "tst1-test2", "display_name": "tst1-test2" }, "name": "Port 10", "cable": 1 }, "type": null, "status": { "value": true, "label": "Connected" }, "label": "", "color": "", "length": null, "length_unit": null }, { "id": 2, "termination_a_type": "dcim.consoleport", "termination_a_id": 3, "termination_a": { "id": 3, "url": "http://localhost:8000/api/dcim/console-ports/3/", "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "tst1-test3", "display_name": "tst1-test3" }, "name": "Console", "cable": 2 }, "termination_b_type": "dcim.consoleserverport", "termination_b_id": 4, "termination_b": { "id": 4, "url": "http://localhost:8000/api/dcim/console-server-ports/4/", "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "tst1-test4", "display_name": "tst1-test4" }, "name": "Port 11", "cable": 2 }, "type": null, "status": { "value": true, "label": "Connected" }, "label": "", "color": "", "length": null, "length_unit": null }, { "id": 3, "termination_a_type": "dcim.consoleport", "termination_a_id": 5, "termination_a": { "id": 5, "url": "http://localhost:8000/api/dcim/console-ports/5/", "device": { "id": 5, "url": "http://localhost:8000/api/dcim/devices/5/", "name": "tst1-test5", "display_name": "tst1-test5" }, "name": "Console", "cable": 3 }, "termination_b_type": "dcim.consoleserverport", "termination_b_id": 6, "termination_b": { "id": 6, "url": "http://localhost:8000/api/dcim/console-server-ports/6/", "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "tst1-test6", "display_name": "tst1-test6" }, "name": "Port 1", "cable": 3 }, "type": null, "status": { "value": true, "label": "Connected" }, "label": "", "color": "", "length": null, "length_unit": null } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/choices.json0000644000175100001730000002330314344673022021234 0ustar00runnerdocker{ "device:face": [ { "label": "Front", "value": 0 }, { "label": "Rear", "value": 1 } ], "device:status": [ { "label": "Active", "value": 1 }, { "label": "Offline", "value": 0 }, { "label": "Planned", "value": 2 }, { "label": "Staged", "value": 3 }, { "label": "Failed", "value": 4 }, { "label": "Inventory", "value": 5 } ], "console-port:connection_status": [ { "label": "Planned", "value": false }, { "label": "Connected", "value": true } ], "interface:form_factor": [ { "label": "Virtual", "value": 0 }, { "label": "Link Aggregation Group (LAG)", "value": 200 }, { "label": "100BASE-TX (10/100ME)", "value": 800 }, { "label": "1000BASE-T (1GE)", "value": 1000 }, { "label": "10GBASE-T (10GE)", "value": 1150 }, { "label": "10GBASE-CX4 (10GE)", "value": 1170 }, { "label": "GBIC (1GE)", "value": 1050 }, { "label": "SFP (1GE)", "value": 1100 }, { "label": "SFP+ (10GE)", "value": 1200 }, { "label": "XFP (10GE)", "value": 1300 }, { "label": "XENPAK (10GE)", "value": 1310 }, { "label": "X2 (10GE)", "value": 1320 }, { "label": "SFP28 (25GE)", "value": 1350 }, { "label": "QSFP+ (40GE)", "value": 1400 }, { "label": "CFP (100GE)", "value": 1500 }, { "label": "CFP2 (100GE)", "value": 1510 }, { "label": "CFP4 (100GE)", "value": 1520 }, { "label": "Cisco CPAK (100GE)", "value": 1550 }, { "label": "QSFP28 (100GE)", "value": 1600 }, { "label": "IEEE 802.11a", "value": 2600 }, { "label": "IEEE 802.11b/g", "value": 2610 }, { "label": "IEEE 802.11n", "value": 2620 }, { "label": "IEEE 802.11ac", "value": 2630 }, { "label": "IEEE 802.11ad", "value": 2640 }, { "label": "SFP (1GFC)", "value": 3010 }, { "label": "SFP (2GFC)", "value": 3020 }, { "label": "SFP (4GFC)", "value": 3040 }, { "label": "SFP+ (8GFC)", "value": 3080 }, { "label": "SFP+ (16GFC)", "value": 3160 }, { "label": "T1 (1.544 Mbps)", "value": 4000 }, { "label": "E1 (2.048 Mbps)", "value": 4010 }, { "label": "T3 (45 Mbps)", "value": 4040 }, { "label": "E3 (34 Mbps)", "value": 4050 }, { "label": "Cisco StackWise", "value": 5000 }, { "label": "Cisco StackWise Plus", "value": 5050 }, { "label": "Cisco FlexStack", "value": 5100 }, { "label": "Cisco FlexStack Plus", "value": 5150 }, { "label": "Juniper VCP", "value": 5200 }, { "label": "Extreme SummitStack", "value": 5300 }, { "label": "Extreme SummitStack-128", "value": 5310 }, { "label": "Extreme SummitStack-256", "value": 5320 }, { "label": "Extreme SummitStack-512", "value": 5330 }, { "label": "Other", "value": 32767 } ], "interface:mode": [ { "label": "Access", "value": 100 }, { "label": "Tagged", "value": 200 }, { "label": "Tagged All", "value": 300 } ], "interface-connection:connection_status": [ { "label": "Planned", "value": false }, { "label": "Connected", "value": true } ], "interface-template:form_factor": [ { "label": "Virtual", "value": 0 }, { "label": "Link Aggregation Group (LAG)", "value": 200 }, { "label": "100BASE-TX (10/100ME)", "value": 800 }, { "label": "1000BASE-T (1GE)", "value": 1000 }, { "label": "10GBASE-T (10GE)", "value": 1150 }, { "label": "10GBASE-CX4 (10GE)", "value": 1170 }, { "label": "GBIC (1GE)", "value": 1050 }, { "label": "SFP (1GE)", "value": 1100 }, { "label": "SFP+ (10GE)", "value": 1200 }, { "label": "XFP (10GE)", "value": 1300 }, { "label": "XENPAK (10GE)", "value": 1310 }, { "label": "X2 (10GE)", "value": 1320 }, { "label": "SFP28 (25GE)", "value": 1350 }, { "label": "QSFP+ (40GE)", "value": 1400 }, { "label": "CFP (100GE)", "value": 1500 }, { "label": "CFP2 (100GE)", "value": 1510 }, { "label": "CFP4 (100GE)", "value": 1520 }, { "label": "Cisco CPAK (100GE)", "value": 1550 }, { "label": "QSFP28 (100GE)", "value": 1600 }, { "label": "IEEE 802.11a", "value": 2600 }, { "label": "IEEE 802.11b/g", "value": 2610 }, { "label": "IEEE 802.11n", "value": 2620 }, { "label": "IEEE 802.11ac", "value": 2630 }, { "label": "IEEE 802.11ad", "value": 2640 }, { "label": "SFP (1GFC)", "value": 3010 }, { "label": "SFP (2GFC)", "value": 3020 }, { "label": "SFP (4GFC)", "value": 3040 }, { "label": "SFP+ (8GFC)", "value": 3080 }, { "label": "SFP+ (16GFC)", "value": 3160 }, { "label": "T1 (1.544 Mbps)", "value": 4000 }, { "label": "E1 (2.048 Mbps)", "value": 4010 }, { "label": "T3 (45 Mbps)", "value": 4040 }, { "label": "E3 (34 Mbps)", "value": 4050 }, { "label": "Cisco StackWise", "value": 5000 }, { "label": "Cisco StackWise Plus", "value": 5050 }, { "label": "Cisco FlexStack", "value": 5100 }, { "label": "Cisco FlexStack Plus", "value": 5150 }, { "label": "Juniper VCP", "value": 5200 }, { "label": "Extreme SummitStack", "value": 5300 }, { "label": "Extreme SummitStack-128", "value": 5310 }, { "label": "Extreme SummitStack-256", "value": 5320 }, { "label": "Extreme SummitStack-512", "value": 5330 }, { "label": "Other", "value": 32767 } ], "power-port:connection_status": [ { "label": "Planned", "value": false }, { "label": "Connected", "value": true } ], "rack:type": [ { "label": "2-post frame", "value": 100 }, { "label": "4-post frame", "value": 200 }, { "label": "4-post cabinet", "value": 300 }, { "label": "Wall-mounted frame", "value": 1000 }, { "label": "Wall-mounted cabinet", "value": 1100 } ], "rack:width": [ { "label": "19 inches", "value": 19 }, { "label": "23 inches", "value": 23 } ], "site:status": [ { "label": "Active", "value": 1 }, { "label": "Planned", "value": 2 }, { "label": "Retired", "value": 4 } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/console_port.json0000644000175100001730000000102614344673022022323 0ustar00runnerdocker{ "id": 1, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "Console (RE0)", "cs_port": { "id": 27, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 3", "connected_console": 1 }, "connection_status": true }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/console_port_template.json0000644000175100001730000000061114344673022024215 0ustar00runnerdocker{ "id": 1, "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "name": "Console (RE0)" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/console_port_templates.json0000644000175100001730000000726714344673022024416 0ustar00runnerdocker{ "count": 7, "next": null, "previous": null, "results": [ { "id": 3, "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "name": "Console (RE0)" }, { "id": 4, "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "name": "Console (RE1)" }, { "id": 1, "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "name": "Console (RE0)" }, { "id": 2, "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "name": "Console (RE1)" }, { "id": 5, "device_type": { "id": 3, "url": "http://localhost:8000/api/dcim/device-types/3/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-24Q", "slug": "qfx5100-24q" }, "name": "Console" }, { "id": 6, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Console" }, { "id": 7, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "Serial" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/console_ports.json0000644000175100001730000001664014344673022022516 0ustar00runnerdocker{ "count": 15, "next": null, "previous": null, "results": [ { "id": 3, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "Console (RE0)", "cs_port": { "id": 5, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 1", "connected_console": 3 }, "connection_status": true }, { "id": 4, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "Console (RE1)", "cs_port": { "id": 16, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 2", "connected_console": 4 }, "connection_status": true }, { "id": 11, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "Console (RE0)", "cs_port": null, "connection_status": true }, { "id": 12, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "Console (RE1)", "cs_port": null, "connection_status": true }, { "id": 1, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "Console (RE0)", "cs_port": { "id": 27, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 3", "connected_console": 1 }, "connection_status": true }, { "id": 2, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "Console (RE1)", "cs_port": { "id": 38, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 4", "connected_console": 2 }, "connection_status": true }, { "id": 9, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "Console (RE0)", "cs_port": null, "connection_status": true }, { "id": 10, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "Console (RE1)", "cs_port": null, "connection_status": true }, { "id": 6, "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "test1-leaf1", "display_name": "test1-leaf1" }, "name": "Console", "cs_port": { "id": 48, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 5", "connected_console": 6 }, "connection_status": true }, { "id": 7, "device": { "id": 5, "url": "http://localhost:8000/api/dcim/devices/5/", "name": "test1-leaf2", "display_name": "test1-leaf2" }, "name": "Console", "cs_port": null, "connection_status": true }, { "id": 13, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Console", "cs_port": null, "connection_status": true }, { "id": 15, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "Serial", "cs_port": null, "connection_status": true }, { "id": 16, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "Serial", "cs_port": null, "connection_status": true }, { "id": 5, "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "Console", "cs_port": { "id": 49, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 6", "connected_console": 5 }, "connection_status": true }, { "id": 8, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "Console", "cs_port": null, "connection_status": true } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/console_server_port.json0000644000175100001730000000035014344673022023710 0ustar00runnerdocker{ "id": 1, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 1", "connected_console": 3 }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/console_server_port_template.json0000644000175100001730000000061714344673022025611 0ustar00runnerdocker{ "id": 1, "device_type": { "id": 3, "url": "http://localhost:8000/api/dcim/device-types/3/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-24Q", "slug": "qfx5100-24q" }, "name": "Console" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/console_server_port_templates.json0000644000175100001730000006310514344673022025775 0ustar00runnerdocker{ "count": 50, "next": null, "previous": null, "results": [ { "id": 1, "device_type": { "id": 3, "url": "http://localhost:8000/api/dcim/device-types/3/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-24Q", "slug": "qfx5100-24q" }, "name": "Console" }, { "id": 3, "device_type": { "id": 4, "url": "http://localhost:8000/api/dcim/device-types/4/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-48S", "slug": "qfx5100-48s" }, "name": "Console" }, { "id": 4, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 1" }, { "id": 13, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 10" }, { "id": 14, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 11" }, { "id": 15, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 12" }, { "id": 16, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 13" }, { "id": 17, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 14" }, { "id": 18, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 15" }, { "id": 19, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 16" }, { "id": 20, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 17" }, { "id": 21, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 18" }, { "id": 22, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 19" }, { "id": 5, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 2" }, { "id": 23, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 20" }, { "id": 24, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 21" }, { "id": 25, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 22" }, { "id": 26, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 23" }, { "id": 27, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 24" }, { "id": 28, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 25" }, { "id": 29, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 26" }, { "id": 30, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 27" }, { "id": 31, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 28" }, { "id": 32, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 29" }, { "id": 6, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 3" }, { "id": 33, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 30" }, { "id": 34, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 31" }, { "id": 35, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 32" }, { "id": 36, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 33" }, { "id": 37, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 34" }, { "id": 38, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 35" }, { "id": 39, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 36" }, { "id": 40, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 37" }, { "id": 41, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 38" }, { "id": 42, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 39" }, { "id": 7, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 4" }, { "id": 43, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 40" }, { "id": 44, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 41" }, { "id": 45, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 42" }, { "id": 46, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 43" }, { "id": 47, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 44" }, { "id": 48, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 45" }, { "id": 49, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 46" }, { "id": 50, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 47" }, { "id": 51, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 48" }, { "id": 8, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 5" }, { "id": 9, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 6" }, { "id": 10, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 7" }, { "id": 11, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 8" }, { "id": 12, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "Port 9" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/console_server_ports.json0000644000175100001730000003660214344673022024104 0ustar00runnerdocker{ "count": 48, "next": null, "previous": null, "results": [ { "id": 5, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 1", "connected_console": 3 }, { "id": 16, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 2", "connected_console": 4 }, { "id": 27, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 3", "connected_console": 1 }, { "id": 38, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 4", "connected_console": 2 }, { "id": 48, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 5", "connected_console": 6 }, { "id": 49, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 6", "connected_console": 5 }, { "id": 50, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 7", "connected_console": null }, { "id": 51, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 8", "connected_console": null }, { "id": 52, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 9", "connected_console": null }, { "id": 6, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 10", "connected_console": null }, { "id": 7, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 11", "connected_console": null }, { "id": 8, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 12", "connected_console": null }, { "id": 9, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 13", "connected_console": null }, { "id": 10, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 14", "connected_console": null }, { "id": 11, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 15", "connected_console": null }, { "id": 12, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 16", "connected_console": null }, { "id": 13, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 17", "connected_console": null }, { "id": 14, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 18", "connected_console": null }, { "id": 15, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 19", "connected_console": null }, { "id": 17, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 20", "connected_console": null }, { "id": 18, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 21", "connected_console": null }, { "id": 19, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 22", "connected_console": null }, { "id": 20, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 23", "connected_console": null }, { "id": 21, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 24", "connected_console": null }, { "id": 22, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 25", "connected_console": null }, { "id": 23, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 26", "connected_console": null }, { "id": 24, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 27", "connected_console": null }, { "id": 25, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 28", "connected_console": null }, { "id": 26, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 29", "connected_console": null }, { "id": 28, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 30", "connected_console": null }, { "id": 29, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 31", "connected_console": null }, { "id": 30, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 32", "connected_console": null }, { "id": 31, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 33", "connected_console": null }, { "id": 32, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 34", "connected_console": null }, { "id": 33, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 35", "connected_console": null }, { "id": 34, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 36", "connected_console": null }, { "id": 35, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 37", "connected_console": null }, { "id": 36, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 38", "connected_console": null }, { "id": 37, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 39", "connected_console": null }, { "id": 39, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 40", "connected_console": null }, { "id": 40, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 41", "connected_console": null }, { "id": 41, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 42", "connected_console": null }, { "id": 42, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 43", "connected_console": null }, { "id": 43, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 44", "connected_console": null }, { "id": 44, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 45", "connected_console": null }, { "id": 45, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 46", "connected_console": null }, { "id": 46, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 47", "connected_console": null }, { "id": 47, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "Port 48", "connected_console": null } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device.json0000644000175100001730000000346114344673022021061 0ustar00runnerdocker{ "id": 1, "name": "test1-edge1", "display_name": "test1-edge1", "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "device_role": { "id": 1, "url": "http://localhost:8000/api/dcim/device-roles/1/", "name": "Router", "slug": "router" }, "tenant": null, "platform": { "id": 1, "url": "http://localhost:8000/api/dcim/platforms/1/", "name": "Juniper Junos", "slug": "juniper-junos" }, "serial": "5555555555", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 1, "url": "http://localhost:8000/api/dcim/racks/1/", "name": "A1R1", "display_name": "A1R1 (T23A01)" }, "position": 1, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": { "id": 1, "url": "http://localhost:8000/api/ipam/ip-addresses/1/", "family": 4, "address": "10.0.255.1/32" }, "primary_ip4": { "id": 1, "url": "http://localhost:8000/api/ipam/ip-addresses/1/", "family": 4, "address": "10.0.255.1/32" }, "primary_ip6": null, "comments": "", "local_context_data": { "testing": "test" }, "custom_fields": {}, "config_context": { "test_key": "test_val" } } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device_bay.json0000644000175100001730000000037114344673022021711 0ustar00runnerdocker{ "id": 1, "device": { "id": 13, "url": "http://localhost:8000/api/dcim/devices/13/", "name": "test1-mothership", "display_name": "test1-mothership" }, "name": "thing-1", "installed_device": null }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device_bay_template.json0000644000175100001730000000062314344673022023604 0ustar00runnerdocker{ "id": 1, "device_type": { "id": 7, "url": "http://localhost:8000/api/dcim/device-types/7/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "Mothership", "slug": "mothership" }, "name": "thing-1" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device_bay_templates.json0000644000175100001730000000322014344673022023763 0ustar00runnerdocker{ "count": 3, "next": null, "previous": null, "results": [ { "id": 1, "device_type": { "id": 7, "url": "http://localhost:8000/api/dcim/device-types/7/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "Mothership", "slug": "mothership" }, "name": "thing-1" }, { "id": 2, "device_type": { "id": 7, "url": "http://localhost:8000/api/dcim/device-types/7/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "Mothership", "slug": "mothership" }, "name": "thing-2" }, { "id": 3, "device_type": { "id": 7, "url": "http://localhost:8000/api/dcim/device-types/7/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "Mothership", "slug": "mothership" }, "name": "thing-3" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device_bays.json0000644000175100001730000000211214344673022022067 0ustar00runnerdocker{ "count": 3, "next": null, "previous": null, "results": [ { "id": 1, "device": { "id": 13, "url": "http://localhost:8000/api/dcim/devices/13/", "name": "test1-mothership", "display_name": "test1-mothership" }, "name": "thing-1", "installed_device": null }, { "id": 2, "device": { "id": 13, "url": "http://localhost:8000/api/dcim/devices/13/", "name": "test1-mothership", "display_name": "test1-mothership" }, "name": "thing-2", "installed_device": null }, { "id": 3, "device": { "id": 13, "url": "http://localhost:8000/api/dcim/devices/13/", "name": "test1-mothership", "display_name": "test1-mothership" }, "name": "thing-3", "installed_device": null } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device_bulk_create.json0000644000175100001730000000153214344673022023416 0ustar00runnerdocker[ { "id": 1, "name": "test1-core3", "device_type": 1, "device_role": 3, "tenant": null, "platform": null, "serial": "", "asset_tag": null, "site": 1, "rack": null, "position": null, "face": null, "status": 1, "primary_ip4": null, "primary_ip6": null, "cluster": null, "comments": "" }, { "id": 2, "name": "test1-core4", "device_type": 1, "device_role": 3, "tenant": null, "platform": null, "serial": "", "asset_tag": null, "site": 1, "rack": null, "position": null, "face": null, "status": 1, "primary_ip4": null, "primary_ip6": null, "cluster": null, "comments": "" } ]././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device_role.json0000644000175100001730000000012214344673022022071 0ustar00runnerdocker{ "id": 1, "name": "Router", "slug": "router", "color": "purple" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device_roles.json0000644000175100001730000000160514344673022022263 0ustar00runnerdocker{ "count": 6, "next": null, "previous": null, "results": [ { "id": 3, "name": "Core Switch", "slug": "core-switch", "color": "red" }, { "id": 4, "name": "Leaf Switch", "slug": "leaf-switch", "color": "teal" }, { "id": 5, "name": "OOB Switch", "slug": "oob-switch", "color": "purple" }, { "id": 6, "name": "PDU", "slug": "pdu", "color": "yellow" }, { "id": 1, "name": "Router", "slug": "router", "color": "purple" }, { "id": 2, "name": "Spine Switch", "slug": "spine-switch", "color": "green" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device_type.json0000644000175100001730000000106314344673022022116 0ustar00runnerdocker{ "id": 1, "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960", "part_number": "", "u_height": 16, "is_full_depth": true, "interface_ordering": { "value": 1, "label": "Slot/position" }, "is_console_server": false, "is_pdu": false, "is_network_device": true, "subdevice_role": null, "comments": "", "custom_fields": {}, "instance_count": 2 }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/device_types.json0000644000175100001730000001116214344673022022302 0ustar00runnerdocker{ "count": 6, "next": null, "previous": null, "results": [ { "id": 2, "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214", "part_number": "", "u_height": 16, "is_full_depth": true, "interface_ordering": { "value": 1, "label": "Slot/position" }, "is_console_server": false, "is_pdu": false, "is_network_device": true, "subdevice_role": null, "comments": "", "custom_fields": {}, "instance_count": 2 }, { "id": 1, "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960", "part_number": "", "u_height": 16, "is_full_depth": true, "interface_ordering": { "value": 1, "label": "Slot/position" }, "is_console_server": false, "is_pdu": false, "is_network_device": true, "subdevice_role": null, "comments": "", "custom_fields": {}, "instance_count": 2 }, { "id": 3, "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-24Q", "slug": "qfx5100-24q", "part_number": "", "u_height": 1, "is_full_depth": true, "interface_ordering": { "value": 1, "label": "Slot/position" }, "is_console_server": false, "is_pdu": false, "is_network_device": true, "subdevice_role": null, "comments": "", "custom_fields": {}, "instance_count": 2 }, { "id": 4, "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-48S", "slug": "qfx5100-48s", "part_number": "", "u_height": 1, "is_full_depth": true, "interface_ordering": { "value": 1, "label": "Slot/position" }, "is_console_server": false, "is_pdu": false, "is_network_device": true, "subdevice_role": null, "comments": "", "custom_fields": {}, "instance_count": 2 }, { "id": 5, "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148", "part_number": "", "u_height": 1, "is_full_depth": true, "interface_ordering": { "value": 1, "label": "Slot/position" }, "is_console_server": true, "is_pdu": false, "is_network_device": false, "subdevice_role": null, "comments": "", "custom_fields": {}, "instance_count": 1 }, { "id": 6, "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9", "part_number": "", "u_height": 0, "is_full_depth": false, "interface_ordering": { "value": 1, "label": "Slot/position" }, "is_console_server": false, "is_pdu": true, "is_network_device": false, "subdevice_role": null, "comments": "", "custom_fields": {}, "instance_count": 2 } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/devices.json0000644000175100001730000005317214344673022021250 0ustar00runnerdocker{ "count": 11, "next": null, "previous": null, "results": [ { "id": 2, "name": "test1-core1", "display_name": "test1-core1", "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "device_role": { "id": 3, "url": "http://localhost:8000/api/dcim/device-roles/3/", "name": "Core Switch", "slug": "core-switch" }, "tenant": null, "platform": { "id": 1, "url": "http://localhost:8000/api/dcim/platforms/1/", "name": "Juniper Junos", "slug": "juniper-junos" }, "serial": "", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 1, "url": "http://localhost:8000/api/dcim/racks/1/", "name": "A1R1", "display_name": "A1R1 (T23A01)" }, "position": 17, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": { "id": 5, "url": "http://localhost:8000/api/ipam/ip-addresses/5/", "family": 4, "address": "10.0.254.1/24" }, "primary_ip4": { "id": 5, "url": "http://localhost:8000/api/ipam/ip-addresses/5/", "family": 4, "address": "10.0.254.1/24" }, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 8, "name": "test1-core2", "display_name": "test1-core2", "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "device_role": { "id": 3, "url": "http://localhost:8000/api/dcim/device-roles/3/", "name": "Core Switch", "slug": "core-switch" }, "tenant": null, "platform": { "id": 1, "url": "http://localhost:8000/api/dcim/platforms/1/", "name": "Juniper Junos", "slug": "juniper-junos" }, "serial": "67856734534", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 2, "url": "http://localhost:8000/api/dcim/racks/2/", "name": "A1R2", "display_name": "A1R2 (T24A01)" }, "position": 17, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": { "id": 19, "url": "http://localhost:8000/api/ipam/ip-addresses/19/", "family": 4, "address": "10.0.254.2/32" }, "primary_ip4": { "id": 19, "url": "http://localhost:8000/api/ipam/ip-addresses/19/", "family": 4, "address": "10.0.254.2/32" }, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 1, "name": "test1-edge1", "display_name": "test1-edge1", "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "device_role": { "id": 1, "url": "http://localhost:8000/api/dcim/device-roles/1/", "name": "Router", "slug": "router" }, "tenant": null, "platform": { "id": 1, "url": "http://localhost:8000/api/dcim/platforms/1/", "name": "Juniper Junos", "slug": "juniper-junos" }, "serial": "5555555555", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 1, "url": "http://localhost:8000/api/dcim/racks/1/", "name": "A1R1", "display_name": "A1R1 (T23A01)" }, "position": 1, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": { "id": 1, "url": "http://localhost:8000/api/ipam/ip-addresses/1/", "family": 4, "address": "10.0.255.1/32" }, "primary_ip4": { "id": 1, "url": "http://localhost:8000/api/ipam/ip-addresses/1/", "family": 4, "address": "10.0.255.1/32" }, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 7, "name": "test1-edge2", "display_name": "test1-edge2", "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "device_role": { "id": 1, "url": "http://localhost:8000/api/dcim/device-roles/1/", "name": "Router", "slug": "router" }, "tenant": null, "platform": { "id": 1, "url": "http://localhost:8000/api/dcim/platforms/1/", "name": "Juniper Junos", "slug": "juniper-junos" }, "serial": "7567356345", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 2, "url": "http://localhost:8000/api/dcim/racks/2/", "name": "A1R2", "display_name": "A1R2 (T24A01)" }, "position": 1, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": { "id": 3, "url": "http://localhost:8000/api/ipam/ip-addresses/3/", "family": 4, "address": "10.0.255.2/32" }, "primary_ip4": { "id": 3, "url": "http://localhost:8000/api/ipam/ip-addresses/3/", "family": 4, "address": "10.0.255.2/32" }, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 4, "name": "test1-leaf1", "display_name": "test1-leaf1", "device_type": { "id": 4, "url": "http://localhost:8000/api/dcim/device-types/4/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-48S", "slug": "qfx5100-48s" }, "device_role": { "id": 4, "url": "http://localhost:8000/api/dcim/device-roles/4/", "name": "Leaf Switch", "slug": "leaf-switch" }, "tenant": null, "platform": { "id": 1, "url": "http://localhost:8000/api/dcim/platforms/1/", "name": "Juniper Junos", "slug": "juniper-junos" }, "serial": "", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 1, "url": "http://localhost:8000/api/dcim/racks/1/", "name": "A1R1", "display_name": "A1R1 (T23A01)" }, "position": 34, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 5, "name": "test1-leaf2", "display_name": "test1-leaf2", "device_type": { "id": 4, "url": "http://localhost:8000/api/dcim/device-types/4/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-48S", "slug": "qfx5100-48s" }, "device_role": { "id": 4, "url": "http://localhost:8000/api/dcim/device-roles/4/", "name": "Leaf Switch", "slug": "leaf-switch" }, "tenant": null, "platform": { "id": 1, "url": "http://localhost:8000/api/dcim/platforms/1/", "name": "Juniper Junos", "slug": "juniper-junos" }, "serial": "9823478293748", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 2, "url": "http://localhost:8000/api/dcim/racks/2/", "name": "A1R2", "display_name": "A1R2 (T24A01)" }, "position": 34, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 9, "name": "test1-oob1", "display_name": "test1-oob1", "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "device_role": { "id": 5, "url": "http://localhost:8000/api/dcim/device-roles/5/", "name": "OOB Switch", "slug": "oob-switch" }, "tenant": null, "platform": { "id": 2, "url": "http://localhost:8000/api/dcim/platforms/2/", "name": "Opengear", "slug": "opengear" }, "serial": "98273942938", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 1, "url": "http://localhost:8000/api/dcim/racks/1/", "name": "A1R1", "display_name": "A1R1 (T23A01)" }, "position": 42, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 11, "name": "test1-pdu1", "display_name": "test1-pdu1", "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "device_role": { "id": 6, "url": "http://localhost:8000/api/dcim/device-roles/6/", "name": "PDU", "slug": "pdu" }, "tenant": null, "platform": null, "serial": "", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 1, "url": "http://localhost:8000/api/dcim/racks/1/", "name": "A1R1", "display_name": "A1R1 (T23A01)" }, "position": null, "face": null, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 12, "name": "test1-pdu2", "display_name": "test1-pdu2", "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "device_role": { "id": 6, "url": "http://localhost:8000/api/dcim/device-roles/6/", "name": "PDU", "slug": "pdu" }, "tenant": null, "platform": null, "serial": "", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 2, "url": "http://localhost:8000/api/dcim/racks/2/", "name": "A1R2", "display_name": "A1R2 (T24A01)" }, "position": null, "face": null, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 3, "name": "test1-spine1", "display_name": "test1-spine1", "device_type": { "id": 3, "url": "http://localhost:8000/api/dcim/device-types/3/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-24Q", "slug": "qfx5100-24q" }, "device_role": { "id": 2, "url": "http://localhost:8000/api/dcim/device-roles/2/", "name": "Spine Switch", "slug": "spine-switch" }, "tenant": null, "platform": { "id": 1, "url": "http://localhost:8000/api/dcim/platforms/1/", "name": "Juniper Junos", "slug": "juniper-junos" }, "serial": "", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 1, "url": "http://localhost:8000/api/dcim/racks/1/", "name": "A1R1", "display_name": "A1R1 (T23A01)" }, "position": 33, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "comments": "", "custom_fields": {} }, { "id": 6, "name": "test1-spine2", "display_name": "test1-spine2", "device_type": { "id": 3, "url": "http://localhost:8000/api/dcim/device-types/3/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-24Q", "slug": "qfx5100-24q" }, "device_role": { "id": 2, "url": "http://localhost:8000/api/dcim/device-roles/2/", "name": "Spine Switch", "slug": "spine-switch" }, "tenant": null, "platform": { "id": 1, "url": "http://localhost:8000/api/dcim/platforms/1/", "name": "Juniper Junos", "slug": "juniper-junos" }, "serial": "45649818158", "asset_tag": null, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "rack": { "id": 2, "url": "http://localhost:8000/api/dcim/racks/2/", "name": "A1R2", "display_name": "A1R2 (T24A01)" }, "position": 33, "face": { "value": 0, "label": "Front" }, "parent_device": null, "status": { "value": true, "label": "Active" }, "primary_ip": null, "primary_ip4": null, "primary_ip6": null, "comments": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/interface.json0000644000175100001730000000313214344673022021555 0ustar00runnerdocker{ "id": 1, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/0/0", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "enabled": true, "lag": { "id": 223, "url": "http://localhost:8000/api/dcim/interfaces/223/", "name": "ae0" }, "mtu": null, "mac_address": null, "mgmt_only": false, "description": "", "is_connected": true, "connected_endpoint": { "id": 1, "url": "http://localhost:8000/api/dcim/interfaces/1/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "tst-endpoint", "display_name": "tst-endpoint" }, "name": "eth0", "cable": 1 }, "connection_status": { "value": true, "label": "Connected" }, "cable": { "id": 1, "url": "http://localhost:8000/api/dcim/cables/1/", "label": "" }, "mode": { "value": "tagged", "label": "Tagged", "id": 200 }, "untagged_vlan": { "id": 2, "url": "http://localhost:8000/api/ipam/vlans/792/", "vid": 2069, "name": "v2069", "display_name": "2069 (v2069)" }, "tagged_vlans": [ { "id": 3, "url": "http://localhost:8000/api/ipam/vlans/248/", "vid": 1210, "name": "v1210", "display_name": "1210 (v1210)" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/interface_connection.json0000644000175100001730000000173714344673022024005 0ustar00runnerdocker{ "id": 1, "interface_a": { "id": 99, "url": "http://localhost:8000/api/dcim/interfaces/99/", "device": { "id": 5, "url": "http://localhost:8000/api/dcim/devices/5/", "name": "test1-leaf2", "display_name": "test1-leaf2" }, "name": "et-0/0/48", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 15, "url": "http://localhost:8000/api/dcim/interfaces/15/", "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "et-0/0/1", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/interface_connections.json0000644000175100001730000005276014344673022024172 0ustar00runnerdocker{ "count": 17, "next": null, "previous": null, "results": [ { "id": 22, "interface_a": { "id": 9, "url": "http://localhost:8000/api/dcim/interfaces/9/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 218, "url": "http://localhost:8000/api/dcim/interfaces/218/", "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 23, "interface_a": { "id": 8, "url": "http://localhost:8000/api/dcim/interfaces/8/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 206, "url": "http://localhost:8000/api/dcim/interfaces/206/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 24, "interface_a": { "id": 7, "url": "http://localhost:8000/api/dcim/interfaces/7/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/3", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 212, "url": "http://localhost:8000/api/dcim/interfaces/212/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 21, "interface_a": { "id": 194, "url": "http://localhost:8000/api/dcim/interfaces/194/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 200, "url": "http://localhost:8000/api/dcim/interfaces/200/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 17, "interface_a": { "id": 192, "url": "http://localhost:8000/api/dcim/interfaces/192/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 175, "url": "http://localhost:8000/api/dcim/interfaces/175/", "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 20, "interface_a": { "id": 191, "url": "http://localhost:8000/api/dcim/interfaces/191/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/0/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 197, "url": "http://localhost:8000/api/dcim/interfaces/197/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/0/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 16, "interface_a": { "id": 189, "url": "http://localhost:8000/api/dcim/interfaces/189/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/0/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 37, "url": "http://localhost:8000/api/dcim/interfaces/37/", "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 8, "interface_a": { "id": 92, "url": "http://localhost:8000/api/dcim/interfaces/92/", "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "test1-leaf1", "display_name": "test1-leaf1" }, "name": "xe-0/0/47", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 145, "url": "http://localhost:8000/api/dcim/interfaces/145/", "device": { "id": 5, "url": "http://localhost:8000/api/dcim/devices/5/", "name": "test1-leaf2", "display_name": "test1-leaf2" }, "name": "xe-0/0/47", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 7, "interface_a": { "id": 91, "url": "http://localhost:8000/api/dcim/interfaces/91/", "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "test1-leaf1", "display_name": "test1-leaf1" }, "name": "xe-0/0/46", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 144, "url": "http://localhost:8000/api/dcim/interfaces/144/", "device": { "id": 5, "url": "http://localhost:8000/api/dcim/devices/5/", "name": "test1-leaf2", "display_name": "test1-leaf2" }, "name": "xe-0/0/46", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 6, "interface_a": { "id": 47, "url": "http://localhost:8000/api/dcim/interfaces/47/", "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "test1-leaf1", "display_name": "test1-leaf1" }, "name": "et-0/0/49", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 152, "url": "http://localhost:8000/api/dcim/interfaces/152/", "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 5, "interface_a": { "id": 46, "url": "http://localhost:8000/api/dcim/interfaces/46/", "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "test1-leaf1", "display_name": "test1-leaf1" }, "name": "et-0/0/48", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 14, "url": "http://localhost:8000/api/dcim/interfaces/14/", "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "et-0/0/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 4, "interface_a": { "id": 100, "url": "http://localhost:8000/api/dcim/interfaces/100/", "device": { "id": 5, "url": "http://localhost:8000/api/dcim/devices/5/", "name": "test1-leaf2", "display_name": "test1-leaf2" }, "name": "et-0/0/49", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 153, "url": "http://localhost:8000/api/dcim/interfaces/153/", "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/1", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 3, "interface_a": { "id": 99, "url": "http://localhost:8000/api/dcim/interfaces/99/", "device": { "id": 5, "url": "http://localhost:8000/api/dcim/devices/5/", "name": "test1-leaf2", "display_name": "test1-leaf2" }, "name": "et-0/0/48", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 15, "url": "http://localhost:8000/api/dcim/interfaces/15/", "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "et-0/0/1", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 25, "interface_a": { "id": 217, "url": "http://localhost:8000/api/dcim/interfaces/217/", "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 205, "url": "http://localhost:8000/api/dcim/interfaces/205/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 26, "interface_a": { "id": 216, "url": "http://localhost:8000/api/dcim/interfaces/216/", "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/3", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 211, "url": "http://localhost:8000/api/dcim/interfaces/211/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 19, "interface_a": { "id": 198, "url": "http://localhost:8000/api/dcim/interfaces/198/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 179, "url": "http://localhost:8000/api/dcim/interfaces/179/", "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } }, { "id": 18, "interface_a": { "id": 195, "url": "http://localhost:8000/api/dcim/interfaces/195/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/0/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "interface_b": { "id": 41, "url": "http://localhost:8000/api/dcim/interfaces/41/", "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "et-0/2/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" }, "connection_status": { "value": true, "label": "Connected" } } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/interface_template.json0000644000175100001730000000076414344673022023460 0ustar00runnerdocker{ "id": 1, "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "name": "fxp0 (RE0)", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "mgmt_only": true }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/interface_templates.json0000644000175100001730000000262114344673022023635 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 4, "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "name": "fxp0 (RE0)", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "mgmt_only": true }, { "id": 5, "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "name": "fxp0 (RE1)", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "mgmt_only": true } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/interface_trace.json0000644000175100001730000000677014344673022022746 0ustar00runnerdocker[ [ { "id": 39126, "url": "http://localhost:8000/api/dcim/interfaces/39126/", "device": { "id": 4747, "url": "http://localhost:8000/api/dcim/devices/4747/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "em1", "cable": 9911, "connection_status": { "value": false, "label": "Not Connected" } }, { "id": 9911, "url": "http://localhost:8000/api/dcim/cables/9911/", "type": "", "status": "planned", "label": "", "color": "", "length": null, "length_unit": "" }, { "id": 5583, "url": "http://localhost:8000/api/dcim/front-ports/5583/", "device": { "id": 4430, "url": "http://localhost:8000/api/dcim/devices/4430/", "name": "test1-patchpanel1", "display_name": "test1-patchpanel1" }, "name": "pair-11 (ports 21-22)", "cable": 9911 } ], [ { "id": 3736, "url": "http://localhost:8000/api/dcim/rear-ports/3736/", "device": { "id": 4430, "url": "http://localhost:8000/api/dcim/devices/4430/", "name": "test1-patchpanel1", "display_name": "test1-patchpanel1" }, "name": "port-2", "cable": 9229 }, { "id": 9229, "url": "http://localhost:8000/api/dcim/cables/9229/", "type": "mmf-om4", "status": "planned", "label": "", "color": "", "length": null, "length_unit": "" }, { "id": 3768, "url": "http://localhost:8000/api/dcim/rear-ports/3768/", "device": { "id": 4436, "url": "http://localhost:8000/api/dcim/devices/4436/", "name": "test1-patchpanel2", "display_name": "test1-patchpanel2" }, "name": "port-2", "cable": 9229 } ], [ { "id": 5655, "url": "http://localhost:8000/api/dcim/front-ports/5655/", "device": { "id": 4436, "url": "http://localhost:8000/api/dcim/devices/4436/", "name": "test1-patchpanel2", "display_name": "test1-patchpanel2" }, "name": "pair-11 (ports 21-22)", "cable": 9240 }, { "id": 9240, "url": "http://localhost:8000/api/dcim/cables/9240/", "type": "mmf-om4", "status": "planned", "label": "", "color": "", "length": null, "length_unit": "" }, { "id": 35473, "url": "http://localhost:8000/api/dcim/interfaces/35473/", "device": { "id": 3930, "url": "http://localhost:8000/api/dcim/devices/3930/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "Ethernet11", "cable": 9240, "connection_status": { "value": false, "label": "Not Connected" } } ] ] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/interfaces.json0000644000175100001730000003356714344673022021757 0ustar00runnerdocker{ "count": 221, "next": null, "previous": "http://localhost:8000/api/dcim/interfaces/?limit=50&offset=150", "results": [ { "id": 162, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/18", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 163, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/19", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 164, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 165, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/20", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 166, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/21", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 167, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/22", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 168, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/3", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 169, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/4", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 170, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/5", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 171, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/6", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 172, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/7", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 173, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/8", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 174, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/9", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 175, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/0", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 17, "url": "http://localhost:8000/api/dcim/interface-connections/17/", "connection_status": true }, "connected_interface": { "id": 192, "url": "http://localhost:8000/api/dcim/interfaces/192/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 176, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/1", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 177, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 178, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/3", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 179, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/0", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 19, "url": "http://localhost:8000/api/dcim/interface-connections/19/", "connection_status": true }, "connected_interface": { "id": 198, "url": "http://localhost:8000/api/dcim/interfaces/198/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 180, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/1", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 181, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 182, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/3", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/interfaces_1.json0000644000175100001730000012450714344673022022172 0ustar00runnerdocker{ "count": 221, "next": "http://localhost:8000/api/dcim/interfaces/?limit=50&offset=50", "previous": null, "results": [ { "id": 189, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/0/0", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 16, "url": "http://localhost:8000/api/dcim/interface-connections/16/", "connection_status": true }, "connected_interface": { "id": 37, "url": "http://localhost:8000/api/dcim/interfaces/37/", "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 190, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/0/1", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 191, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/0/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 20, "url": "http://localhost:8000/api/dcim/interface-connections/20/", "connection_status": true }, "connected_interface": { "id": 197, "url": "http://localhost:8000/api/dcim/interfaces/197/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/0/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 192, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/0", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 17, "url": "http://localhost:8000/api/dcim/interface-connections/17/", "connection_status": true }, "connected_interface": { "id": 175, "url": "http://localhost:8000/api/dcim/interfaces/175/", "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 193, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/1", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 194, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 21, "url": "http://localhost:8000/api/dcim/interface-connections/21/", "connection_status": true }, "connected_interface": { "id": 200, "url": "http://localhost:8000/api/dcim/interfaces/200/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 10, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "fxp0 (RE0)", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "lag": null, "mac_address": null, "mgmt_only": true, "description": "", "connection": null, "connected_interface": null }, { "id": 11, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "fxp0 (RE1)", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "lag": null, "mac_address": null, "mgmt_only": true, "description": "", "connection": null, "connected_interface": null }, { "id": 12, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "lo0", "form_factor": { "value": 0, "label": "Virtual" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 201, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/0", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 202, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/1", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 203, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/2", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 204, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/3", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 205, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/4", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 25, "url": "http://localhost:8000/api/dcim/interface-connections/25/", "connection_status": true }, "connected_interface": { "id": 217, "url": "http://localhost:8000/api/dcim/interfaces/217/", "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 206, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/5", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 23, "url": "http://localhost:8000/api/dcim/interface-connections/23/", "connection_status": true }, "connected_interface": { "id": 8, "url": "http://localhost:8000/api/dcim/interfaces/8/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 195, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/0/0", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 18, "url": "http://localhost:8000/api/dcim/interface-connections/18/", "connection_status": true }, "connected_interface": { "id": 41, "url": "http://localhost:8000/api/dcim/interfaces/41/", "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "et-0/2/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 196, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/0/1", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 197, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/0/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 20, "url": "http://localhost:8000/api/dcim/interface-connections/20/", "connection_status": true }, "connected_interface": { "id": 191, "url": "http://localhost:8000/api/dcim/interfaces/191/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/0/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 198, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/0", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 19, "url": "http://localhost:8000/api/dcim/interface-connections/19/", "connection_status": true }, "connected_interface": { "id": 179, "url": "http://localhost:8000/api/dcim/interfaces/179/", "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 199, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/1", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 200, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 21, "url": "http://localhost:8000/api/dcim/interface-connections/21/", "connection_status": true }, "connected_interface": { "id": 194, "url": "http://localhost:8000/api/dcim/interfaces/194/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 186, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "fxp0 (RE0)", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "lag": null, "mac_address": null, "mgmt_only": true, "description": "", "connection": null, "connected_interface": null }, { "id": 187, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "fxp0 (RE1)", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "lag": null, "mac_address": null, "mgmt_only": true, "description": "", "connection": null, "connected_interface": null }, { "id": 188, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "lo0", "form_factor": { "value": 0, "label": "Virtual" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 207, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/0", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 208, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/1", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 209, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/2", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 210, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/3", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 211, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/4", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 26, "url": "http://localhost:8000/api/dcim/interface-connections/26/", "connection_status": true }, "connected_interface": { "id": 216, "url": "http://localhost:8000/api/dcim/interfaces/216/", "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/3", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 212, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/5", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 24, "url": "http://localhost:8000/api/dcim/interface-connections/24/", "connection_status": true }, "connected_interface": { "id": 7, "url": "http://localhost:8000/api/dcim/interfaces/7/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/3", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 1, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "fxp0 (RE0)", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "lag": null, "mac_address": null, "mgmt_only": true, "description": "", "connection": null, "connected_interface": null }, { "id": 2, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "fxp0 (RE1)", "form_factor": { "value": 800, "label": "100BASE-TX (10/100ME)" }, "lag": null, "mac_address": null, "mgmt_only": true, "description": "", "connection": null, "connected_interface": null }, { "id": 3, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "lo0", "form_factor": { "value": 0, "label": "Virtual" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 4, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/0", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "TEST", "connection": null, "connected_interface": null }, { "id": 5, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/1", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 6, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/2", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 7, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/3", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 24, "url": "http://localhost:8000/api/dcim/interface-connections/24/", "connection_status": true }, "connected_interface": { "id": 212, "url": "http://localhost:8000/api/dcim/interfaces/212/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 8, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/4", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 23, "url": "http://localhost:8000/api/dcim/interface-connections/23/", "connection_status": true }, "connected_interface": { "id": 206, "url": "http://localhost:8000/api/dcim/interfaces/206/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 9, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/5", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 22, "url": "http://localhost:8000/api/dcim/interface-connections/22/", "connection_status": true }, "connected_interface": { "id": 218, "url": "http://localhost:8000/api/dcim/interfaces/218/", "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 183, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "fxp0 (RE0)", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "lag": null, "mac_address": null, "mgmt_only": true, "description": "", "connection": null, "connected_interface": null }, { "id": 184, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "fxp0 (RE1)", "form_factor": { "value": 800, "label": "100BASE-TX (10/100ME)" }, "lag": null, "mac_address": null, "mgmt_only": true, "description": "", "connection": null, "connected_interface": null }, { "id": 185, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "lo0", "form_factor": { "value": 0, "label": "Virtual" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 213, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/0", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 214, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/1", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 215, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/2", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 216, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/3", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 26, "url": "http://localhost:8000/api/dcim/interface-connections/26/", "connection_status": true }, "connected_interface": { "id": 211, "url": "http://localhost:8000/api/dcim/interfaces/211/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 217, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/4", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 25, "url": "http://localhost:8000/api/dcim/interface-connections/25/", "connection_status": true }, "connected_interface": { "id": 205, "url": "http://localhost:8000/api/dcim/interfaces/205/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 218, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/5", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 22, "url": "http://localhost:8000/api/dcim/interface-connections/22/", "connection_status": true }, "connected_interface": { "id": 9, "url": "http://localhost:8000/api/dcim/interfaces/9/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 45, "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "test1-leaf1", "display_name": "test1-leaf1" }, "name": "em0", "form_factor": { "value": 1000, "label": "1000BASE-T (1GE)" }, "lag": null, "mac_address": "FF:EE:DD:33:22:11", "mgmt_only": true, "description": "", "connection": null, "connected_interface": null }, { "id": 46, "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "test1-leaf1", "display_name": "test1-leaf1" }, "name": "et-0/0/48", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 5, "url": "http://localhost:8000/api/dcim/interface-connections/5/", "connection_status": true }, "connected_interface": { "id": 14, "url": "http://localhost:8000/api/dcim/interfaces/14/", "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "et-0/0/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/interfaces_2.json0000644000175100001730000003356714344673022022200 0ustar00runnerdocker{ "count": 221, "next": null, "previous": "http://localhost:8000/api/dcim/interfaces/?limit=50&offset=150", "results": [ { "id": 162, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/18", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 163, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/19", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 164, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 165, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/20", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 166, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/21", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 167, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/22", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 168, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/3", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 169, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/4", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 170, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/5", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 171, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/6", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 172, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/7", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 173, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/8", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 174, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/0/9", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 175, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/0", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 17, "url": "http://localhost:8000/api/dcim/interface-connections/17/", "connection_status": true }, "connected_interface": { "id": 192, "url": "http://localhost:8000/api/dcim/interfaces/192/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 176, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/1", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 177, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 178, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/1/3", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 179, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/0", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 19, "url": "http://localhost:8000/api/dcim/interface-connections/19/", "connection_status": true }, "connected_interface": { "id": 198, "url": "http://localhost:8000/api/dcim/interfaces/198/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/0", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, { "id": 180, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/1", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 181, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, { "id": 182, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "et-0/2/3", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/inventory_item.json0000644000175100001730000000003614344673022022670 0ustar00runnerdocker{ "detail": "Not found." }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/inventory_items.json0000644000175100001730000000011514344673022023051 0ustar00runnerdocker{ "count": 0, "next": null, "previous": null, "results": [] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/manufacturer.json0000644000175100001730000000007514344673022022314 0ustar00runnerdocker{ "id": 1, "name": "Juniper", "slug": "juniper" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/manufacturers.json0000644000175100001730000000061614344673022022500 0ustar00runnerdocker{ "count": 3, "next": null, "previous": null, "results": [ { "id": 1, "name": "Juniper", "slug": "juniper" }, { "id": 2, "name": "Opengear", "slug": "opengear" }, { "id": 3, "name": "ServerTech", "slug": "servertech" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/napalm.json0000644000175100001730000000044614344673022021072 0ustar00runnerdocker{ "get_facts": { "interface_list": [ "xe-0/0/0" ], "serial_number": "ABC!@#", "vendor": "PacketPusher", "os_version": "1.1", "hostname": "test-1", "model": "UnobtaniumX", "fqdn": "None", "uptime": 2 } }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/platform.json0000644000175100001730000000015414344673022021442 0ustar00runnerdocker{ "id": 1, "name": "Juniper Junos", "slug": "juniper-junos", "rpc_client": "juniper-junos" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/platforms.json0000644000175100001730000000057614344673022021635 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "name": "Juniper Junos", "slug": "juniper-junos", "rpc_client": "juniper-junos" }, { "id": 2, "name": "Opengear", "slug": "opengear", "rpc_client": "opengear" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/power_outlet.json0000644000175100001730000000034414344673022022347 0ustar00runnerdocker{ "id": 1, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA1", "connected_port": 1 }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/power_outlet_template.json0000644000175100001730000000062714344673022024246 0ustar00runnerdocker{ "id": 1, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AA1" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/power_outlet_templates.json0000644000175100001730000003127414344673022024433 0ustar00runnerdocker{ "count": 24, "next": null, "previous": null, "results": [ { "id": 4, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AA1" }, { "id": 5, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AA2" }, { "id": 6, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AA3" }, { "id": 7, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AA4" }, { "id": 8, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AA5" }, { "id": 9, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AA6" }, { "id": 10, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AA7" }, { "id": 11, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AA8" }, { "id": 12, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AB1" }, { "id": 13, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AB2" }, { "id": 14, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AB3" }, { "id": 15, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AB4" }, { "id": 16, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AB5" }, { "id": 17, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AB6" }, { "id": 18, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AB7" }, { "id": 19, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AB8" }, { "id": 20, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AC1" }, { "id": 21, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AC2" }, { "id": 22, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AC3" }, { "id": 23, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AC4" }, { "id": 24, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AC5" }, { "id": 25, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AC6" }, { "id": 26, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AC7" }, { "id": 27, "device_type": { "id": 6, "url": "http://localhost:8000/api/dcim/device-types/6/", "manufacturer": { "id": 3, "url": "http://localhost:8000/api/dcim/manufacturers/3/", "name": "ServerTech", "slug": "servertech" }, "model": "CWG-24VYM415C9", "slug": "cwg-24vym415c9" }, "name": "AC8" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/power_outlets.json0000644000175100001730000003621514344673022022540 0ustar00runnerdocker{ "count": 48, "next": null, "previous": null, "results": [ { "id": 25, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA1", "connected_port": 1 }, { "id": 26, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA2", "connected_port": 5 }, { "id": 27, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA3", "connected_port": 13 }, { "id": 28, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA4", "connected_port": 9 }, { "id": 29, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA5", "connected_port": 16 }, { "id": 30, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA6", "connected_port": 20 }, { "id": 31, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA7", "connected_port": 24 }, { "id": 32, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA8", "connected_port": 12 }, { "id": 33, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AB1", "connected_port": null }, { "id": 34, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AB2", "connected_port": null }, { "id": 35, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AB3", "connected_port": null }, { "id": 36, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AB4", "connected_port": null }, { "id": 37, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AB5", "connected_port": null }, { "id": 38, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AB6", "connected_port": null }, { "id": 39, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AB7", "connected_port": null }, { "id": 40, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AB8", "connected_port": null }, { "id": 41, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AC1", "connected_port": null }, { "id": 42, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AC2", "connected_port": null }, { "id": 43, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AC3", "connected_port": null }, { "id": 44, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AC4", "connected_port": null }, { "id": 45, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AC5", "connected_port": null }, { "id": 46, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AC6", "connected_port": null }, { "id": 47, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AC7", "connected_port": null }, { "id": 48, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AC8", "connected_port": null }, { "id": 49, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA1", "connected_port": 2 }, { "id": 50, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA2", "connected_port": 6 }, { "id": 51, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA3", "connected_port": 14 }, { "id": 52, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA4", "connected_port": 10 }, { "id": 53, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA5", "connected_port": 15 }, { "id": 54, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA6", "connected_port": 19 }, { "id": 55, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA7", "connected_port": 23 }, { "id": 56, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA8", "connected_port": 11 }, { "id": 57, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AB1", "connected_port": null }, { "id": 58, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AB2", "connected_port": null }, { "id": 59, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AB3", "connected_port": null }, { "id": 60, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AB4", "connected_port": null }, { "id": 61, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AB5", "connected_port": null }, { "id": 62, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AB6", "connected_port": null }, { "id": 63, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AB7", "connected_port": null }, { "id": 64, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AB8", "connected_port": null }, { "id": 65, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AC1", "connected_port": null }, { "id": 66, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AC2", "connected_port": null }, { "id": 67, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AC3", "connected_port": null }, { "id": 68, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AC4", "connected_port": null }, { "id": 69, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AC5", "connected_port": null }, { "id": 70, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AC6", "connected_port": null }, { "id": 71, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AC7", "connected_port": null }, { "id": 72, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AC8", "connected_port": null } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/power_port.json0000644000175100001730000000101614344673022022014 0ustar00runnerdocker{ "id": 1, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "PEM0", "power_outlet": { "id": 25, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA1", "connected_port": 1 }, "connection_status": true }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/power_port_template.json0000644000175100001730000000060014344673022023705 0ustar00runnerdocker{ "id": 1, "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "name": "PEM0" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/power_port_templates.json0000644000175100001730000001525314344673022024102 0ustar00runnerdocker{ "count": 13, "next": null, "previous": null, "results": [ { "id": 5, "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "name": "PEM0" }, { "id": 6, "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "name": "PEM1" }, { "id": 7, "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "name": "PEM2" }, { "id": 8, "device_type": { "id": 2, "url": "http://localhost:8000/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "EX9214", "slug": "ex9214" }, "name": "PEM3" }, { "id": 1, "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "name": "PEM0" }, { "id": 2, "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "name": "PEM1" }, { "id": 3, "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "name": "PEM2" }, { "id": 4, "device_type": { "id": 1, "url": "http://localhost:8000/api/dcim/device-types/1/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "MX960", "slug": "mx960" }, "name": "PEM3" }, { "id": 11, "device_type": { "id": 3, "url": "http://localhost:8000/api/dcim/device-types/3/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-24Q", "slug": "qfx5100-24q" }, "name": "PSU0" }, { "id": 12, "device_type": { "id": 3, "url": "http://localhost:8000/api/dcim/device-types/3/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-24Q", "slug": "qfx5100-24q" }, "name": "PSU1" }, { "id": 9, "device_type": { "id": 4, "url": "http://localhost:8000/api/dcim/device-types/4/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-48S", "slug": "qfx5100-48s" }, "name": "PSU0" }, { "id": 13, "device_type": { "id": 4, "url": "http://localhost:8000/api/dcim/device-types/4/", "manufacturer": { "id": 1, "url": "http://localhost:8000/api/dcim/manufacturers/1/", "name": "Juniper", "slug": "juniper" }, "model": "QFX5100-48S", "slug": "qfx5100-48s" }, "name": "PSU1" }, { "id": 14, "device_type": { "id": 5, "url": "http://localhost:8000/api/dcim/device-types/5/", "manufacturer": { "id": 2, "url": "http://localhost:8000/api/dcim/manufacturers/2/", "name": "Opengear", "slug": "opengear" }, "model": "CM4148", "slug": "cm4148" }, "name": "PSU" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/power_ports.json0000644000175100001730000003442114344673022022205 0ustar00runnerdocker{ "count": 25, "next": null, "previous": null, "results": [ { "id": 5, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "PEM0", "power_outlet": { "id": 26, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA2", "connected_port": 5 }, "connection_status": true }, { "id": 6, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "PEM1", "power_outlet": { "id": 50, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA2", "connected_port": 6 }, "connection_status": true }, { "id": 7, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "PEM2", "power_outlet": null, "connection_status": true }, { "id": 8, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "PEM3", "power_outlet": null, "connection_status": true }, { "id": 19, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "PEM0", "power_outlet": { "id": 54, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA6", "connected_port": 19 }, "connection_status": true }, { "id": 20, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "PEM1", "power_outlet": { "id": 30, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA6", "connected_port": 20 }, "connection_status": true }, { "id": 21, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "PEM2", "power_outlet": null, "connection_status": true }, { "id": 22, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "PEM3", "power_outlet": null, "connection_status": true }, { "id": 1, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "PEM0", "power_outlet": { "id": 25, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA1", "connected_port": 1 }, "connection_status": true }, { "id": 2, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "PEM1", "power_outlet": { "id": 49, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA1", "connected_port": 2 }, "connection_status": true }, { "id": 3, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "PEM2", "power_outlet": null, "connection_status": true }, { "id": 4, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "PEM3", "power_outlet": null, "connection_status": true }, { "id": 15, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "PEM0", "power_outlet": { "id": 53, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA5", "connected_port": 15 }, "connection_status": true }, { "id": 16, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "PEM1", "power_outlet": { "id": 29, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA5", "connected_port": 16 }, "connection_status": true }, { "id": 17, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "PEM2", "power_outlet": null, "connection_status": true }, { "id": 18, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "PEM3", "power_outlet": null, "connection_status": true }, { "id": 9, "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "test1-leaf1", "display_name": "test1-leaf1" }, "name": "PSU0", "power_outlet": { "id": 28, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA4", "connected_port": 9 }, "connection_status": true }, { "id": 10, "device": { "id": 4, "url": "http://localhost:8000/api/dcim/devices/4/", "name": "test1-leaf1", "display_name": "test1-leaf1" }, "name": "PSU1", "power_outlet": { "id": 52, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA4", "connected_port": 10 }, "connection_status": true }, { "id": 11, "device": { "id": 5, "url": "http://localhost:8000/api/dcim/devices/5/", "name": "test1-leaf2", "display_name": "test1-leaf2" }, "name": "PSU0", "power_outlet": { "id": 56, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA8", "connected_port": 11 }, "connection_status": true }, { "id": 12, "device": { "id": 5, "url": "http://localhost:8000/api/dcim/devices/5/", "name": "test1-leaf2", "display_name": "test1-leaf2" }, "name": "PSU1", "power_outlet": { "id": 32, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA8", "connected_port": 12 }, "connection_status": true }, { "id": 25, "device": { "id": 9, "url": "http://localhost:8000/api/dcim/devices/9/", "name": "test1-oob1", "display_name": "test1-oob1" }, "name": "PSU", "power_outlet": null, "connection_status": true }, { "id": 13, "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "PSU0", "power_outlet": { "id": 27, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA3", "connected_port": 13 }, "connection_status": true }, { "id": 14, "device": { "id": 3, "url": "http://localhost:8000/api/dcim/devices/3/", "name": "test1-spine1", "display_name": "test1-spine1" }, "name": "PSU1", "power_outlet": { "id": 51, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA3", "connected_port": 14 }, "connection_status": true }, { "id": 23, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "PSU0", "power_outlet": { "id": 55, "device": { "id": 12, "url": "http://localhost:8000/api/dcim/devices/12/", "name": "test1-pdu2", "display_name": "test1-pdu2" }, "name": "AA7", "connected_port": 23 }, "connection_status": true }, { "id": 24, "device": { "id": 6, "url": "http://localhost:8000/api/dcim/devices/6/", "name": "test1-spine2", "display_name": "test1-spine2" }, "name": "PSU1", "power_outlet": { "id": 31, "device": { "id": 11, "url": "http://localhost:8000/api/dcim/devices/11/", "name": "test1-pdu1", "display_name": "test1-pdu1" }, "name": "AA7", "connected_port": 24 }, "connection_status": true } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/rack.json0000644000175100001730000000115314344673022020536 0ustar00runnerdocker{ "id": 1, "name": "A1R1", "facility_id": "T23A01", "display_name": "A1R1 (T23A01)", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "group": null, "tenant": null, "role": { "id": 1, "url": "http://localhost:8000/api/dcim/rack-roles/1/", "name": "Compute", "slug": "compute" }, "type": null, "width": { "value": 19, "label": "19 inches" }, "u_height": 42, "desc_units": false, "comments": "", "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/rack_group.json0000644000175100001730000000031014344673022021744 0ustar00runnerdocker{ "id": 1, "name": "TEST", "slug": "test", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" } }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/rack_groups.json0000644000175100001730000000056314344673022022141 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "TEST", "slug": "test", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" } } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/rack_reservation.json0000644000175100001730000000046414344673022023163 0ustar00runnerdocker{ "id": 1, "rack": { "id": 2, "url": "http://localhost:8000/api/dcim/racks/2/", "name": "A1R2", "display_name": "A1R2 (T24A01)" }, "units": [ 42 ], "created": "2017-03-22T04:10:47.307156Z", "user": 1, "description": "Test Reservation" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/rack_reservations.json0000644000175100001730000000077714344673022023355 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "rack": { "id": 2, "url": "http://localhost:8000/api/dcim/racks/2/", "name": "A1R2", "display_name": "A1R2 (T24A01)" }, "units": [ 42 ], "created": "2017-03-22T04:10:47.307156Z", "user": 1, "description": "Test Reservation" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/rack_role.json0000644000175100001730000000011614344673022021555 0ustar00runnerdocker{ "id": 1, "name": "Test", "slug": "test", "color": "aa1409" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/rack_roles.json0000644000175100001730000000032114344673022021736 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "Test", "slug": "test", "color": "aa1409" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/rack_u.json0000644000175100001730000000146514344673022021070 0ustar00runnerdocker{ "count": 3, "next": null, "previous": null, "results": [ { "id": 48, "name": "U1", "face": 0, "device": { "id": 130, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "tst-device1", "display_name": "tst-device1" } }, { "id": 47, "name": "U2", "face": 0, "device": null }, { "id": 46, "name": "U3", "face": 0, "device": { "id": 1859, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "tst-device2", "display_name": "tst-device2" } } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/racks.json0000644000175100001730000000263314344673022020725 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "name": "A1R1", "facility_id": "T23A01", "display_name": "A1R1 (T23A01)", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "group": null, "tenant": null, "role": null, "type": null, "width": { "value": 19, "label": "19 inches" }, "u_height": 42, "desc_units": false, "comments": "", "custom_fields": {} }, { "id": 2, "name": "A1R2", "facility_id": "T24A01", "display_name": "A1R2 (T24A01)", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "group": null, "tenant": null, "role": null, "type": null, "width": { "value": 19, "label": "19 inches" }, "u_height": 42, "desc_units": false, "comments": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/region.json0000644000175100001730000000011314344673022021074 0ustar00runnerdocker{ "id": 1, "name": "TEST", "slug": "test", "parent": null }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/regions.json0000644000175100001730000000031614344673022021264 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "TEST", "slug": "test", "parent": null } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/site.json0000644000175100001730000000113214344673022020557 0ustar00runnerdocker{ "id": 1, "name": "TEST1", "slug": "test1", "region": null, "tenant": null, "facility": "Test Facility", "asn": 65535, "physical_address": "555 Test Ave.\r\nTest, NY 55555", "shipping_address": "", "contact_name": "", "contact_phone": "", "contact_email": "", "comments": "", "custom_fields": { "test_custom": "Hello", "test_selection": { "value": 2, "label": "second" } }, "count_prefixes": 2, "count_vlans": 1, "count_racks": 2, "count_devices": 11, "count_circuits": 0 }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/sites.json0000644000175100001730000000141014344673022020741 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "TEST1", "slug": "test1", "region": null, "tenant": null, "facility": "Test Facility", "asn": 65535, "physical_address": "555 Test Ave.\r\nTest, NY 55555", "shipping_address": "", "contact_name": "", "contact_phone": "", "contact_email": "", "comments": "", "custom_fields": { "test_custom": "Hello" }, "count_prefixes": 2, "count_vlans": 1, "count_racks": 2, "count_devices": 11, "count_circuits": 0 } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/virtual_chassis_device.json0000644000175100001730000000036614344673022024345 0ustar00runnerdocker{ "id": 1, "master": { "id": 5654, "url": "http://localhost:8000/api/dcim/devices/5654/", "name": "01-0001-e214-as01 (SW1)", "display_name": "01-0001-e214-as01 (SW1)" }, "domain": "test-domain-1" } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/dcim/virtual_chassis_devices.json0000644000175100001730000000136314344673022024526 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "master": { "id": 5654, "url": "http://localhost:8000/api/dcim/devices/5654/", "name": "01-0001-e214-as01 (SW1)", "display_name": "01-0001-e214-as01 (SW1)" }, "domain": "test-domain-1" }, { "id": 2, "master": { "id": 5635, "url": "http://localhost:8000/netbox/api/dcim/devices/5635/", "name": "hercules.router.com (VSS-SW1)", "display_name": "hercules.router.com (VSS-SW1)" }, "domain": "test-domain-2" } ] } ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.222451 pynetbox-7.0.0/tests/fixtures/ipam/0000755000175100001730000000000014344673035016741 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/aggregate.json0000644000175100001730000000042714344673022021561 0ustar00runnerdocker{ "id": 1, "family": 4, "prefix": "10.0.0.0/8", "rir": { "id": 1, "url": "http://localhost:8000/api/ipam/rirs/1/", "name": "RFC1918", "slug": "rfc1918" }, "date_added": null, "description": "", "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/aggregates.json0000644000175100001730000000073214344673022021743 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "family": 4, "prefix": "10.0.0.0/8", "rir": { "id": 1, "url": "http://localhost:8000/api/ipam/rirs/1/", "name": "RFC1918", "slug": "rfc1918" }, "date_added": null, "description": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/available-ips-post.json0000644000175100001730000000027314344673022023326 0ustar00runnerdocker{ "id": 1, "address": "10.1.1.1/32", "vrf": null, "tenant": null, "status": 1, "role": null, "interface": null, "description": "", "nat_inside": null }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/available-ips.json0000644000175100001730000000041214344673022022336 0ustar00runnerdocker[ { "family": 4, "address": "10.1.1.2/27", "vrf": null }, { "family": 4, "address": "10.1.1.3/27", "vrf": null }, { "family": 4, "address": "10.1.1.7/27", "vrf": null } ]././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/available-prefixes-post.json0000644000175100001730000000037114344673022024357 0ustar00runnerdocker[ { "id": 4, "prefix": "10.1.1.0/30", "site": null, "vrf": null, "tenant": null, "vlan": null, "status": 1, "role": null, "is_pool": false, "description": "" } ]././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/available-prefixes.json0000644000175100001730000000013114344673022023366 0ustar00runnerdocker[ { "family": 4, "prefix": "10.1.1.0/24", "vrf": null } ]././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/ip_address.json0000644000175100001730000000142214344673022021744 0ustar00runnerdocker{ "id": 1, "family": 4, "address": "10.0.255.1/32", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 3, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "lo0", "form_factor": { "value": 0, "label": "Virtual" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/ip_addresses.json0000644000175100001730000007003614344673022022303 0ustar00runnerdocker{ "count": 18, "next": null, "previous": null, "results": [ { "id": 5, "family": 4, "address": "10.0.254.1/24", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 12, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "lo0", "form_factor": { "value": 0, "label": "Virtual" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 19, "family": 4, "address": "10.0.254.2/32", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 188, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "lo0", "form_factor": { "value": 0, "label": "Virtual" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 1, "family": 4, "address": "10.0.255.1/32", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 3, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "lo0", "form_factor": { "value": 0, "label": "Virtual" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 3, "family": 4, "address": "10.0.255.2/32", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 185, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "lo0", "form_factor": { "value": 0, "label": "Virtual" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 11, "family": 4, "address": "10.15.20.1/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 7, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/3", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 24, "url": "http://localhost:8000/api/dcim/interface-connections/24/", "connection_status": true }, "connected_interface": { "id": 212, "url": "http://localhost:8000/api/dcim/interfaces/212/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 8, "family": 4, "address": "10.15.21.1/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 218, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/5", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 22, "url": "http://localhost:8000/api/dcim/interface-connections/22/", "connection_status": true }, "connected_interface": { "id": 9, "url": "http://localhost:8000/api/dcim/interfaces/9/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 9, "family": 4, "address": "10.15.21.2/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 9, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/5", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 22, "url": "http://localhost:8000/api/dcim/interface-connections/22/", "connection_status": true }, "connected_interface": { "id": 218, "url": "http://localhost:8000/api/dcim/interfaces/218/", "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 10, "family": 4, "address": "10.15.22.1/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 8, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/4", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 23, "url": "http://localhost:8000/api/dcim/interface-connections/23/", "connection_status": true }, "connected_interface": { "id": 206, "url": "http://localhost:8000/api/dcim/interfaces/206/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/5", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 13, "family": 4, "address": "10.15.22.2/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 206, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/5", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 23, "url": "http://localhost:8000/api/dcim/interface-connections/23/", "connection_status": true }, "connected_interface": { "id": 8, "url": "http://localhost:8000/api/dcim/interfaces/8/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 17, "family": 4, "address": "10.15.22.2/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 212, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/5", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 24, "url": "http://localhost:8000/api/dcim/interface-connections/24/", "connection_status": true }, "connected_interface": { "id": 7, "url": "http://localhost:8000/api/dcim/interfaces/7/", "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/3", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 12, "family": 4, "address": "10.16.20.1/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 216, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/3", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 26, "url": "http://localhost:8000/api/dcim/interface-connections/26/", "connection_status": true }, "connected_interface": { "id": 211, "url": "http://localhost:8000/api/dcim/interfaces/211/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 16, "family": 4, "address": "10.16.20.2/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 211, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "xe-0/0/4", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 26, "url": "http://localhost:8000/api/dcim/interface-connections/26/", "connection_status": true }, "connected_interface": { "id": 216, "url": "http://localhost:8000/api/dcim/interfaces/216/", "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/3", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 14, "family": 4, "address": "10.16.22.1/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 217, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/4", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 25, "url": "http://localhost:8000/api/dcim/interface-connections/25/", "connection_status": true }, "connected_interface": { "id": 205, "url": "http://localhost:8000/api/dcim/interfaces/205/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 15, "family": 4, "address": "10.16.22.2/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 205, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "xe-0/0/4", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 25, "url": "http://localhost:8000/api/dcim/interface-connections/25/", "connection_status": true }, "connected_interface": { "id": 217, "url": "http://localhost:8000/api/dcim/interfaces/217/", "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/4", "form_factor": 1200, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 4, "family": 4, "address": "169.254.1.1/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 213, "device": { "id": 7, "url": "http://localhost:8000/api/dcim/devices/7/", "name": "test1-edge2", "display_name": "test1-edge2" }, "name": "xe-0/0/0", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": null, "connected_interface": null }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 20, "family": 4, "address": "169.254.1.1/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 200, "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 21, "url": "http://localhost:8000/api/dcim/interface-connections/21/", "connection_status": true }, "connected_interface": { "id": 194, "url": "http://localhost:8000/api/dcim/interfaces/194/", "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 21, "family": 4, "address": "169.254.1.2/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 194, "device": { "id": 2, "url": "http://localhost:8000/api/dcim/devices/2/", "name": "test1-core1", "display_name": "test1-core1" }, "name": "et-0/1/2", "form_factor": { "value": 1400, "label": "QSFP+ (40GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "", "connection": { "id": 21, "url": "http://localhost:8000/api/dcim/interface-connections/21/", "connection_status": true }, "connected_interface": { "id": 200, "url": "http://localhost:8000/api/dcim/interfaces/200/", "device": { "id": 8, "url": "http://localhost:8000/api/dcim/devices/8/", "name": "test1-core2", "display_name": "test1-core2" }, "name": "et-0/1/2", "form_factor": 1400, "mac_address": null, "mgmt_only": false, "description": "" } }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} }, { "id": 2, "family": 4, "address": "169.254.254.1/31", "vrf": null, "tenant": null, "status": { "value": 1, "label": "Active" }, "interface": { "id": 4, "device": { "id": 1, "url": "http://localhost:8000/api/dcim/devices/1/", "name": "test1-edge1", "display_name": "test1-edge1" }, "name": "xe-0/0/0", "form_factor": { "value": 1200, "label": "SFP+ (10GE)" }, "lag": null, "mac_address": null, "mgmt_only": false, "description": "TEST", "connection": null, "connected_interface": null }, "description": "", "nat_inside": null, "nat_outside": null, "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/prefix.json0000644000175100001730000000105514344673022021126 0ustar00runnerdocker{ "id": 1, "family": 4, "prefix": "10.1.1.0/24", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "vrf": null, "tenant": null, "vlan": null, "status": { "value": 1, "label": "Active" }, "role": { "id": 1, "url": "http://localhost:8000/api/ipam/roles/1/", "name": "Lab Network", "slug": "lab-network" }, "is_pool": false, "description": "", "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/prefixes.json0000644000175100001730000000314114344673022021454 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 2, "family": 4, "prefix": "10.0.255.0/24", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "vrf": null, "tenant": null, "vlan": null, "status": { "value": 1, "label": "Active" }, "role": { "id": 1, "url": "http://localhost:8000/api/ipam/roles/1/", "name": "Lab Network", "slug": "lab-network" }, "is_pool": false, "description": "", "custom_fields": {} }, { "id": 1, "family": 4, "prefix": "10.1.1.0/24", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "vrf": null, "tenant": null, "vlan": null, "status": { "value": 1, "label": "Active" }, "role": { "id": 1, "url": "http://localhost:8000/api/ipam/roles/1/", "name": "Lab Network", "slug": "lab-network" }, "is_pool": false, "description": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/rir.json0000644000175100001730000000012614344673022020423 0ustar00runnerdocker{ "id": 1, "name": "RFC1918", "slug": "rfc1918", "is_private": false }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/rirs.json0000644000175100001730000000033114344673022020604 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "RFC1918", "slug": "rfc1918", "is_private": false } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/role.json0000644000175100001730000000013114344673022020564 0ustar00runnerdocker{ "id": 1, "name": "Lab Network", "slug": "lab-network", "weight": 1000 }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/roles.json0000644000175100001730000000033414344673022020754 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "Lab Network", "slug": "lab-network", "weight": 1000 } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/vlan.json0000644000175100001730000000104314344673022020566 0ustar00runnerdocker{ "id": 3, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "group": null, "vid": 1210, "name": "v1210", "tenant": null, "status": { "value": 1, "label": "Active" }, "role": { "id": 1, "url": "http://localhost:8000/api/ipam/roles/1/", "name": "Lab Network", "slug": "lab-network" }, "description": "", "display_name": "1210 (v1210)", "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/vlan_group.json0000644000175100001730000000031014344673022021776 0ustar00runnerdocker{ "id": 1, "name": "TEST", "slug": "test", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" } }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/vlan_groups.json0000644000175100001730000000056314344673022022173 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "TEST", "slug": "test", "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" } } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/vlans.json0000644000175100001730000000445414344673022020762 0ustar00runnerdocker{ "count": 3, "next": null, "previous": null, "results": [ { "id": 1, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "group": null, "vid": 999, "name": "TEST", "tenant": null, "status": { "value": 1, "label": "Active" }, "role": { "id": 1, "url": "http://localhost:8000/api/ipam/roles/1/", "name": "Lab Network", "slug": "lab-network" }, "description": "", "display_name": "999 (TEST)", "custom_fields": {} }, { "id": 2, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "group": null, "vid": 2069, "name": "v2069", "tenant": null, "status": { "value": 1, "label": "Active" }, "role": { "id": 1, "url": "http://localhost:8000/api/ipam/roles/1/", "name": "Lab Network", "slug": "lab-network" }, "description": "", "display_name": "2069 (v2069)", "custom_fields": {} }, { "id": 3, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "group": null, "vid": 1210, "name": "v1210", "tenant": null, "status": { "value": 1, "label": "Active" }, "role": { "id": 1, "url": "http://localhost:8000/api/ipam/roles/1/", "name": "Lab Network", "slug": "lab-network" }, "description": "", "display_name": "1210 (v1210)", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/vrf.json0000644000175100001730000000023014344673022020420 0ustar00runnerdocker{ "id": 1, "name": "TEST", "rd": "65535:1", "tenant": null, "enforce_unique": true, "description": "", "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/ipam/vrfs.json0000644000175100001730000000046314344673022020613 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "TEST", "rd": "65535:1", "tenant": null, "enforce_unique": true, "description": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.222451 pynetbox-7.0.0/tests/fixtures/tenancy/0000755000175100001730000000000014344673035017454 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/tenancy/tenant.json0000644000175100001730000000046414344673022021640 0ustar00runnerdocker{ "id": 1, "name": "TEST Tenant 1", "slug": "test-tenant-1", "group": { "id": 1, "url": "http://localhost:8000/api/tenancy/tenant-groups/1/", "name": "TEST Group", "slug": "test-group" }, "description": "", "comments": "", "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/tenancy/tenant_group.json0000644000175100001730000000010314344673022023042 0ustar00runnerdocker{ "id": 1, "name": "TEST Group", "slug": "test-group" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/tenancy/tenant_groups.json0000644000175100001730000000027614344673022023240 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "TEST Group", "slug": "test-group" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/tenancy/tenants.json0000644000175100001730000000163514344673022022024 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "name": "TEST Tenant 1", "slug": "test-tenant-1", "group": { "id": 1, "url": "http://localhost:8000/api/tenancy/tenant-groups/1/", "name": "TEST Group", "slug": "test-group" }, "description": "", "comments": "", "custom_fields": {} }, { "id": 2, "name": "TEST Tenant 2", "slug": "test-tenant-2", "group": { "id": 1, "url": "http://localhost:8000/api/tenancy/tenant-groups/1/", "name": "TEST Group", "slug": "test-group" }, "description": "", "comments": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.222451 pynetbox-7.0.0/tests/fixtures/users/0000755000175100001730000000000014344673035017154 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/users/group.json0000644000175100001730000000005214344673022021174 0ustar00runnerdocker{ "id": 1, "name": "usergroup1" } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/users/groups.json0000644000175100001730000000035014344673022021360 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "name": "usergroup1" }, { "id": 2, "name": "usergroup2" } ] } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/users/permission.json0000644000175100001730000000016514344673022022235 0ustar00runnerdocker{ "id": 1, "name": "permission1", "users": [ { "username": "user1" } ] } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/users/permissions.json0000644000175100001730000000035214344673022022416 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "name": "permission1" }, { "id": 2, "name": "permission2" } ] } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/users/unknown_model.json0000644000175100001730000000006114344673022022717 0ustar00runnerdocker{ "id": 1, "display": "Unknown object" } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/users/user.json0000644000175100001730000000005114344673022021015 0ustar00runnerdocker{ "id": 1, "username": "user1" } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/users/users.json0000644000175100001730000000034614344673022021207 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "username": "user1" }, { "id": 2, "username": "user2" } ] } ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.226451 pynetbox-7.0.0/tests/fixtures/virtualization/0000755000175100001730000000000014344673035021077 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/cluster.json0000644000175100001730000000112214344673022023443 0ustar00runnerdocker{ "id": 1, "name": "vm-test-cluster", "type": { "id": 1, "url": "http://localhost:8000/api/virtualization/cluster-types/1/", "name": "vm-test-type", "slug": "vm-test-type" }, "group": { "id": 1, "url": "http://localhost:8000/api/virtualization/cluster-groups/1/", "name": "vm-test-group", "slug": "vm-test-group" }, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "comments": "", "custom_fields": {} }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/cluster_group.json0000644000175100001730000000011114344673022024654 0ustar00runnerdocker{ "id": 1, "name": "vm-test-group", "slug": "vm-test-group" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/cluster_groups.json0000644000175100001730000000030414344673022025043 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "vm-test-group", "slug": "vm-test-group" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/cluster_type.json0000644000175100001730000000010714344673022024506 0ustar00runnerdocker{ "id": 1, "name": "vm-test-type", "slug": "vm-test-type" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/cluster_types.json0000644000175100001730000000030214344673022024666 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "vm-test-type", "slug": "vm-test-type" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/clusters.json0000644000175100001730000000154514344673022023637 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "vm-test-cluster", "type": { "id": 1, "url": "http://localhost:8000/api/virtualization/cluster-types/1/", "name": "vm-test-type", "slug": "vm-test-type" }, "group": { "id": 1, "url": "http://localhost:8000/api/virtualization/cluster-groups/1/", "name": "vm-test-group", "slug": "vm-test-group" }, "site": { "id": 1, "url": "http://localhost:8000/api/dcim/sites/1/", "name": "TEST1", "slug": "test1" }, "comments": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/interface.json0000644000175100001730000000042714344673022023731 0ustar00runnerdocker{ "id": 223, "name": "eth0", "virtual_machine": { "id": 1, "url": "http://localhost:8000/api/virtualization/virtual-machines/1/", "name": "vm-test01" }, "enabled": true, "mac_address": null, "mtu": null, "description": "" }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/interfaces.json0000644000175100001730000000152314344673022024112 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 223, "name": "eth0", "virtual_machine": { "id": 1, "url": "http://localhost:8000/api/virtualization/virtual-machines/1/", "name": "vm-test01" }, "enabled": true, "mac_address": null, "mtu": null, "description": "" }, { "id": 224, "name": "eth1", "virtual_machine": { "id": 1, "url": "http://localhost:8000/api/virtualization/virtual-machines/1/", "name": "vm-test01" }, "enabled": true, "mac_address": null, "mtu": null, "description": "" } ] }././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/virtual_machine.json0000644000175100001730000000072014344673022025137 0ustar00runnerdocker{ "id": 1, "name": "vm-test01", "status": { "value": 1, "label": "Active" }, "cluster": { "id": 1, "url": "http://localhost:8000/api/virtualization/clusters/1/", "name": "vm-test-cluster" }, "role": null, "tenant": null, "platform": null, "primary_ip4": null, "primary_ip6": null, "vcpus": 2, "memory": 1024, "disk": 500, "comments": "", "custom_fields": {} } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/virtualization/virtual_machines.json0000644000175100001730000000133214344673022025322 0ustar00runnerdocker{ "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "name": "vm-test01", "status": { "value": 1, "label": "Active" }, "cluster": { "id": 1, "url": "http://localhost:8000/api/virtualization/clusters/1/", "name": "vm-test-cluster" }, "role": null, "tenant": null, "platform": null, "primary_ip4": null, "primary_ip6": null, "vcpus": 2, "memory": 1024, "disk": 500, "comments": "", "custom_fields": {} } ] }././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.226451 pynetbox-7.0.0/tests/fixtures/wireless/0000755000175100001730000000000014344673035017650 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/wireless/wireless_lan.json0000644000175100001730000000004614344673022023226 0ustar00runnerdocker{ "id": 1, "ssid": "SSID 1" } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/fixtures/wireless/wireless_lans.json0000644000175100001730000000034014344673022023406 0ustar00runnerdocker{ "count": 2, "next": null, "previous": null, "results": [ { "id": 1, "ssid": "SSID 1" }, { "id": 2, "ssid": "SSID 2" } ] } ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.226451 pynetbox-7.0.0/tests/integration/0000755000175100001730000000000014344673035016465 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/integration/conftest.py0000644000175100001730000004216114344673022020664 0ustar00runnerdockerimport os from packaging import version import subprocess as subp import time import yaml from http.client import RemoteDisconnected import atexit import pynetbox import pytest import requests DOCKER_PROJECT_PREFIX = "pytest_pynetbox" def get_netbox_docker_version_tag(netbox_version): """Get the repo tag to build netbox-docker in from the requested netbox version. Args: netbox_version (version.Version): The version of netbox we want to build Returns: str: The release tag for the netbox-docker repo that should be able to build the requested version of netbox. """ major, minor = netbox_version.major, netbox_version.minor if (major, minor) == (3, 3): tag = "2.2.0" else: raise NotImplementedError( "Version %s is not currently supported" % netbox_version ) return tag @pytest.fixture(scope="session") def git_toplevel(): """Get the top level of the current git repo. Returns: str: The path of the top level directory of the current git repo. """ try: subp.check_call(["which", "git"]) except subp.CalledProcessError: pytest.skip(msg="git executable was not found on the host") return ( subp.check_output(["git", "rev-parse", "--show-toplevel"]) .decode("utf-8") .splitlines()[0] ) @pytest.fixture(scope="session") def netbox_docker_repo_dirpaths(pytestconfig, git_toplevel): """Get the path to the netbox-docker repos we will use. Returns: dict: A map of the repo dir paths to the versions of netbox that should be run from that repo as: { : [ , ..., ] } """ try: subp.check_call(["which", "docker"]) except subp.CalledProcessError: pytest.skip(msg="docker executable was not found on the host") netbox_versions_by_repo_dirpaths = {} for netbox_version in pytestconfig.option.netbox_versions: repo_version_tag = get_netbox_docker_version_tag(netbox_version=netbox_version) print("top: ", git_toplevel) repo_fpath = os.path.join( git_toplevel, ".netbox-docker-%s" % str(repo_version_tag) ) if os.path.isdir(repo_fpath): subp.check_call( ["git", "fetch"], cwd=repo_fpath, stdout=subp.PIPE, stderr=subp.PIPE ) subp.check_call( ["git", "reset", "--hard"], cwd=repo_fpath, stdout=subp.PIPE, stderr=subp.PIPE, ) subp.check_call( ["git", "pull", "origin", "release"], cwd=repo_fpath, stdout=subp.PIPE, stderr=subp.PIPE, ) else: subp.check_call( [ "git", "clone", "https://github.com/netbox-community/netbox-docker", repo_fpath, ], cwd=git_toplevel, stdout=subp.PIPE, stderr=subp.PIPE, ) subp.check_call( ["git", "checkout", repo_version_tag], cwd=repo_fpath, stdout=subp.PIPE, stderr=subp.PIPE, ) try: netbox_versions_by_repo_dirpaths[repo_fpath].append(netbox_version) except KeyError: netbox_versions_by_repo_dirpaths[repo_fpath] = [netbox_version] return netbox_versions_by_repo_dirpaths @pytest.fixture(scope="session") def docker_compose_project_name(pytestconfig): """Get the project name to use for docker containers. This will return a consistently generated project name so we can kill stale containers after the test run is finished. """ return "%s_%s" % (DOCKER_PROJECT_PREFIX, int(time.time())) def clean_netbox_docker_tmpfiles(): """Clean up any temporary files created in the netbox-docker repo.""" dirpath, dirnames, filenames = next(os.walk("./")) for filename in filenames: if filename.startswith("docker-compose-v"): os.remove(filename) def clean_docker_objects(): """Clean up any docker objects created via these tests.""" # clean up any containers for line in subp.check_output(["docker", "ps", "-a"]).decode("utf-8").splitlines(): words = line.split() if not words: continue if words[-1].startswith(DOCKER_PROJECT_PREFIX): subp.check_call( ["docker", "rm", "-f", words[0]], stdout=subp.PIPE, stderr=subp.PIPE ) # clean up any volumes for line in ( subp.check_output(["docker", "volume", "list"]).decode("utf-8").splitlines() ): words = line.split() if not words: continue if words[-1].startswith(DOCKER_PROJECT_PREFIX): subp.check_call( ["docker", "volume", "rm", "-f", words[-1]], stdout=subp.PIPE, stderr=subp.PIPE, ) # clean up any networks for line in ( subp.check_output(["docker", "network", "list"]).decode("utf-8").splitlines() ): words = line.split() if not words: continue if words[1].startswith(DOCKER_PROJECT_PREFIX): subp.check_call( ["docker", "network", "rm", words[1]], stdout=subp.PIPE, stderr=subp.PIPE, ) # TODO: this function could be split up @pytest.fixture(scope="session") def docker_compose_file(pytestconfig, netbox_docker_repo_dirpaths): """Return paths to the compose files needed to create test containers. We can create container sets for multiple versions of netbox here by returning a list of paths to multiple compose files. """ clean_netbox_docker_tmpfiles() clean_docker_objects() compose_files = [] for ( netbox_docker_repo_dirpath, netbox_versions, ) in netbox_docker_repo_dirpaths.items(): compose_source_fpath = os.path.join( netbox_docker_repo_dirpath, "docker-compose.yml" ) for netbox_version in netbox_versions: # check for updates to the local netbox images subp.check_call( ["docker", "pull", "netboxcommunity/netbox:v%s" % (netbox_version)], stdout=subp.PIPE, stderr=subp.PIPE, ) docker_netbox_version = str(netbox_version).replace(".", "_") # load the compose file yaml compose_data = yaml.safe_load(open(compose_source_fpath, "r").read()) # add the custom network for this version docker_network_name = "%s_v%s" % ( DOCKER_PROJECT_PREFIX, docker_netbox_version, ) 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": compose_data["networks"][docker_network_name][ "name" ] = docker_network_name # prepend the netbox version to each of the service names and anything else # needed to make the continers unique to the netbox version new_services = {} for service_name in compose_data["services"].keys(): new_service_name = "netbox_v%s_%s" % ( docker_netbox_version, service_name, ) new_services[new_service_name] = compose_data["services"][service_name] if service_name in ["netbox", "netbox-worker"]: # set the netbox image version new_services[new_service_name]["image"] = ( "netboxcommunity/netbox:v%s" % netbox_version ) if service_name == "netbox": # ensure the netbox container listens on a random port new_services[new_service_name]["ports"] = ["8080"] # set the network and an alias to the proper short name of the container # within that network new_services[new_service_name]["networks"] = { docker_network_name: {"aliases": [service_name]} } # fix the naming of any dependencies if "depends_on" in new_services[new_service_name]: new_service_dependencies = [] for dependent_service_name in new_services[new_service_name][ "depends_on" ]: new_service_dependencies.append( "netbox_v%s_%s" % ( docker_netbox_version, dependent_service_name, ) ) new_services[new_service_name][ "depends_on" ] = new_service_dependencies # make any internal named volumes unique to the netbox version if "volumes" in new_services[new_service_name]: new_volumes = [] for volume_config in new_services[new_service_name]["volumes"]: source = volume_config.split(":")[0] if "/" in source: if volume_config.startswith("./"): # Set the full path to the volume source. Without this # some of the containers would be spun up from the # wrong source directories. volume_source, volume_dest = volume_config.split( ":", maxsplit=1 ) volume_source = os.path.join( netbox_docker_repo_dirpath, volume_source[2::] ) new_volumes.append( ":".join([volume_source, volume_dest]) ) else: new_volumes.append(volume_config) else: new_volumes.append( "%s_v%s_%s" % ( DOCKER_PROJECT_PREFIX, docker_netbox_version, volume_config, ) ) new_services[new_service_name]["volumes"] = new_volumes # replace the services config with the renamed versions compose_data["services"] = new_services # prepend local volume names new_volumes = {} for volume_name, volume_config in compose_data["volumes"].items(): new_volumes[ "%s_v%s_%s" % ( DOCKER_PROJECT_PREFIX, docker_netbox_version, volume_name, ) ] = volume_config compose_data["volumes"] = new_volumes compose_output_fpath = os.path.join( netbox_docker_repo_dirpath, "docker-compose-v%s.yml" % netbox_version, ) with open(compose_output_fpath, "w") as fdesc: fdesc.write(yaml.dump(compose_data)) compose_files.append(compose_output_fpath) # set post=run cleanup hooks if requested if pytestconfig.option.cleanup: atexit.register(clean_docker_objects) atexit.register(clean_netbox_docker_tmpfiles) return compose_files def netbox_is_responsive(url): """Chack if the HTTP service is up and responsive.""" try: response = requests.get(url) if response.status_code == 200: return True except ( ConnectionError, ConnectionResetError, requests.exceptions.ConnectionError, RemoteDisconnected, ): return False def id_netbox_service(fixture_value): """Create and ID representation for a netbox service fixture param. Returns: str: Identifiable representation of the service, as best we can """ return "netbox v%s" % fixture_value @pytest.fixture(scope="session") def docker_netbox_service( pytestconfig, docker_ip, docker_services, request, ): """Get the netbox service to test against. This function waits until the netbox container is fully up and running then does an initial data population with a few object types to be used in testing. Then the service is returned as a fixture to be called from tests. """ netbox_integration_version = request.param netbox_service_name = "netbox_v%s_netbox" % str(netbox_integration_version).replace( ".", "_" ) netbox_service_port = 8080 try: # `port_for` takes a container port and returns the corresponding host port port = docker_services.port_for(netbox_service_name, netbox_service_port) except Exception as err: docker_ps_stdout = subp.check_output(["docker", "ps", "-a"]).decode("utf-8") exited_container_logs = [] for line in docker_ps_stdout.splitlines(): if "Exited" in line: container_id = line.split()[0] exited_container_logs.append( "\nContainer %s logs:\n%s" % ( container_id, subp.check_output(["docker", "logs", container_id]).decode( "utf-8" ), ) ) raise KeyError( "Unable to find a docker service matching the name %s on port %s. Running" " containers: %s. Original error: %s. Logs:\n%s" % ( netbox_service_name, netbox_service_port, docker_ps_stdout, err, exited_container_logs, ) ) url = "http://{}:{}".format(docker_ip, port) docker_services.wait_until_responsive( timeout=300.0, pause=1, check=lambda: netbox_is_responsive(url) ) return { "url": url, "netbox_version": netbox_integration_version, } @pytest.fixture(scope="session") def api(docker_netbox_service): return pynetbox.api( docker_netbox_service["url"], token="0123456789abcdef0123456789abcdef01234567" ) @pytest.fixture(scope="session") def nb_version(docker_netbox_service): return docker_netbox_service["netbox_version"] @pytest.fixture(scope="session") def site(api): site = api.dcim.sites.create(name="test", slug="test") yield site site.delete() @pytest.fixture(scope="session") def manufacturer(api): manufacturer = api.dcim.manufacturers.create( name="test-manufacturer", slug="test-manufacturer" ) yield manufacturer manufacturer.delete() @pytest.fixture(scope="session") def device_type(api, manufacturer): device_type = api.dcim.device_types.create( manufacturer=manufacturer.id, model="test-device-type", slug="test-device-type", height=1, ) yield device_type device_type.delete() @pytest.fixture(scope="session") def device_role(api): device_role = api.dcim.device_roles.create( name="test-device-role", slug="test-device-role", color="000000", ) yield device_role device_role.delete() def pytest_generate_tests(metafunc): """Dynamically parametrize some functions based on args from the cli parser.""" if "docker_netbox_service" in metafunc.fixturenames: # parametrize the requested versions of netbox to the docker_netbox_services fixture # so that it will return a fixture for each of the versions requested # individually rather than one fixture with multiple versions within it metafunc.parametrize( "docker_netbox_service", metafunc.config.getoption("netbox_versions"), ids=id_netbox_service, indirect=True, ) @pytest.fixture(scope="session") def docker_cleanup(pytestconfig): """Override the docker cleanup command for the containsers used in testing.""" # pytest-docker does not always clean up after itself properly, and sometimes it # will fail during cleanup because there is still a connection to one of the # running containers. Here we will disable the builtin cleanup of containers via the # pytest-docker module and implement our own instead. # This is only relevant until https://github.com/avast/pytest-docker/pull/33 gets # resolved. # There is not a great way to skip the shutdown step, so in this case to skip # it we will just pass the "version" arg so the containers are left alone command_args = "version" return command_args ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/integration/test_dcim.py0000644000175100001730000002251514344673022021013 0ustar00runnerdockerimport pytest from packaging import version import pynetbox @pytest.fixture(scope="module") def rack(api, site): rack = api.dcim.racks.create(site=site.id, name="test-rack") yield rack rack.delete() @pytest.fixture(scope="module") def device(api, site, device_type, device_role): device = api.dcim.devices.create( name="test-device", device_role=device_role.id, device_type=device_type.id, site=site.id, color="000000", ) yield device device.delete() @pytest.mark.usefixtures("init") class BaseTest: app = "dcim" def _init_helper( self, request, fixture, update_field=None, filter_kwargs=None, endpoint=None, str_repr=None, ): request.cls.endpoint = endpoint request.cls.fixture = fixture request.cls.update_field = update_field request.cls.filter_kwargs = filter_kwargs request.cls.str_repr = str_repr def test_create(self): assert self.fixture def test_str(self): if self.str_repr: test = str(self.fixture) assert test == self.str_repr def test_update_fixture(self): if self.update_field: setattr(self.fixture, self.update_field, "Test Value") assert self.fixture.save() def test_get_fixture_by_id(self, api): test = getattr(getattr(api, self.app), self.endpoint).get(self.fixture.id) assert test if self.update_field: assert getattr(test, self.update_field) == "Test Value" def test_get_fixture_by_kwarg(self, api): test = getattr(getattr(api, self.app), self.endpoint).get(**self.filter_kwargs) assert test if self.update_field: assert getattr(test, self.update_field) == "Test Value" def test_filter_fixture(self, api): test = list( getattr(getattr(api, self.app), self.endpoint).filter(**self.filter_kwargs) )[0] assert test if self.update_field: assert getattr(test, self.update_field) == "Test Value" class TestSite(BaseTest): @pytest.fixture(scope="class") def init(self, request, site): self._init_helper( request, site, filter_kwargs={"name": "test"}, update_field="description", endpoint="sites", ) @pytest.fixture(scope="class") def add_sites(self, api): sites = api.dcim.sites.create( [ {"name": "test{}".format(i), "slug": "test{}".format(i)} for i in range(2, 20) ] ) yield for i in sites: i.delete() def test_threading_duplicates(self, docker_netbox_service, add_sites): api = pynetbox.api( docker_netbox_service["url"], token="0123456789abcdef0123456789abcdef01234567", threading=True, ) test = api.dcim.sites.all(limit=5) test_list = list(test) test_set = set(test_list) assert len(test_list) == len(test_set) class TestRack(BaseTest): @pytest.fixture(scope="class") def init(self, request, rack): self._init_helper( request, rack, filter_kwargs={"name": rack.name}, update_field="comments", endpoint="racks", ) def test_get_elevation(self): test = self.fixture.elevation.list() assert test assert isinstance(test, list) class TestManufacturer(BaseTest): @pytest.fixture(scope="class") def init(self, request, manufacturer, nb_version): self._init_helper( request, manufacturer, filter_kwargs={"name": manufacturer.name}, update_field="description" if version.parse("2.10") < nb_version else None, endpoint="manufacturers", ) class TestDeviceType(BaseTest): @pytest.fixture(scope="class") def init(self, request, device_type): self._init_helper( request, device_type, filter_kwargs={"model": device_type.model}, update_field="comments", endpoint="device_types", str_repr=device_type.model, ) class TestDevice(BaseTest): @pytest.fixture(scope="class") def init(self, request, device): self._init_helper( request, device, filter_kwargs={"name": device.name}, update_field="comments", endpoint="devices", ) class TestInterface(BaseTest): @pytest.fixture(scope="class") def interface(self, api, device): ret = api.dcim.interfaces.create( name="test-interface", type="1000base-t", device=device.id ) yield ret ret.delete() @pytest.fixture(scope="class") def init(self, request, interface): self._init_helper( request, interface, filter_kwargs={"name": interface.name}, update_field="description", endpoint="interfaces", ) class TestPowerCable(BaseTest): @pytest.fixture(scope="class") def power_outlet(self, api, device_type, device_role, site): pdu = api.dcim.devices.create( name="test-pdu", device_role=device_role.id, device_type=device_type.id, site=site.id, ) outlet = api.dcim.power_outlets.create(name="outlet", device=pdu.id) yield outlet pdu.delete() @pytest.fixture(scope="class") def power_port(self, api, device): ret = api.dcim.power_ports.create(name="PSU1", device=device.id) yield ret @pytest.fixture(scope="class") def power_cable(self, api, power_outlet, power_port): cable = api.dcim.cables.create( a_terminations=[ {"object_type": "dcim.powerport", "object_id": power_port.id}, ], b_terminations=[ {"object_type": "dcim.poweroutlet", "object_id": power_outlet.id}, ], ) yield cable cable.delete() @pytest.fixture(scope="class") def init(self, request, power_cable): self._init_helper( request, power_cable, filter_kwargs={"id": power_cable.id}, endpoint="cables", str_repr="PSU1 <> outlet", ) class TestConsoleCable(BaseTest): @pytest.fixture(scope="class") def console_server_port(self, api, device_type, device_role, site): device = api.dcim.devices.create( name="test-console-server", device_role=device_role.id, device_type=device_type.id, site=site.id, ) ret = api.dcim.console_server_ports.create(name="Port 1", device=device.id) yield ret device.delete() @pytest.fixture(scope="class") def console_port(self, api, device): ret = api.dcim.console_ports.create(name="Console", device=device.id) yield ret @pytest.fixture(scope="class") def console_cable(self, api, console_port, console_server_port): ret = api.dcim.cables.create( a_terminations=[ {"object_type": "dcim.consoleport", "object_id": console_port.id}, ], b_terminations=[ { "object_type": "dcim.consoleserverport", "object_id": console_server_port.id, }, ], ) yield ret ret.delete() @pytest.fixture(scope="class") def init(self, request, console_cable): self._init_helper( request, console_cable, filter_kwargs={"id": console_cable.id}, endpoint="cables", str_repr="Console <> Port 1", ) class TestInterfaceCable(BaseTest): @pytest.fixture(scope="class") def interface_b(self, api, device_type, device_role, site): device = api.dcim.devices.create( name="test-device-2", device_role=device_role.id, device_type=device_type.id, site=site.id, ) ret = api.dcim.interfaces.create( name="Ethernet1", type="1000base-t", device=device.id ) yield ret device.delete() @pytest.fixture(scope="class") def interface_a(self, api, device): ret = api.dcim.interfaces.create( name="Ethernet1", type="1000base-t", device=device.id ) yield ret @pytest.fixture(scope="class") def interface_cable(self, api, interface_a, interface_b): ret = api.dcim.cables.create( a_terminations=[ {"object_type": "dcim.interface", "object_id": interface_a.id}, ], b_terminations=[ {"object_type": "dcim.interface", "object_id": interface_b.id}, ], ) yield ret ret.delete() @pytest.fixture(scope="class") def init(self, request, interface_cable): self._init_helper( request, interface_cable, filter_kwargs={"id": interface_cable.id}, endpoint="cables", str_repr="Ethernet1 <> Ethernet1", ) def test_trace(self, interface_a): test = interface_a.trace() assert test assert test[0][0].name == "Ethernet1" assert test[2][0].name == "Ethernet1" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/integration/test_ipam.py0000644000175100001730000001163614344673022021027 0ustar00runnerdockerimport pytest from packaging import version @pytest.mark.usefixtures("init") class BaseTest: app = "ipam" def _init_helper( self, request, fixture, update_field=None, filter_kwargs=None, endpoint=None, str_repr=None, ): request.cls.endpoint = endpoint request.cls.fixture = fixture request.cls.update_field = update_field request.cls.filter_kwargs = filter_kwargs request.cls.str_repr = str_repr def test_create(self): assert self.fixture def test_str(self): if self.str_repr: test = str(self.fixture) assert test == self.str_repr def test_update_fixture(self): if self.update_field: setattr(self.fixture, self.update_field, "Test Value") assert self.fixture.save() def test_get_fixture_by_id(self, api): test = getattr(getattr(api, self.app), self.endpoint).get(self.fixture.id) assert test if self.update_field: assert getattr(test, self.update_field) == "Test Value" def test_get_fixture_by_kwarg(self, api): test = getattr(getattr(api, self.app), self.endpoint).get(**self.filter_kwargs) assert test if self.update_field: assert getattr(test, self.update_field) == "Test Value" def test_filter_fixture(self, api): test = list( getattr(getattr(api, self.app), self.endpoint).filter(**self.filter_kwargs) )[0] assert test if self.update_field: assert getattr(test, self.update_field) == "Test Value" @pytest.fixture(scope="module") def rir(api, site): ret = api.ipam.rirs.create( name="ministry-of-silly-walks", slug="ministry-of-silly-walks" ) yield ret ret.delete() class TestRIR(BaseTest): @pytest.fixture(scope="class") def init(self, request, rir, nb_version): self._init_helper( request, rir, filter_kwargs={"name": "ministry-of-silly-walks"}, update_field="description" if nb_version >= version.parse("2.8") else None, endpoint="rirs", ) class TestAggregate(BaseTest): @pytest.fixture(scope="class") def aggregate(self, api, rir): ret = api.ipam.aggregates.create(prefix="192.0.2.0/24", rir=rir.id) yield ret ret.delete() @pytest.fixture(scope="class") def init(self, request, aggregate): self._init_helper( request, aggregate, filter_kwargs={"prefix": "192.0.2.0/24"}, update_field="description", endpoint="aggregates", ) class TestPrefix(BaseTest): @pytest.fixture(scope="class") def prefix(self, api): ret = api.ipam.prefixes.create(prefix="192.0.2.0/24") yield ret ret.delete() @pytest.fixture(scope="class") def init(self, request, prefix): self._init_helper( request, prefix, filter_kwargs={"prefix": "192.0.2.0/24"}, update_field="description", endpoint="prefixes", ) class TestIpAddress(BaseTest): @pytest.fixture(scope="class") def ip(self, api): ret = api.ipam.ip_addresses.create(address="192.0.2.1/24") yield ret ret.delete() @pytest.fixture(scope="class") def init(self, request, ip): self._init_helper( request, ip, filter_kwargs={"q": "192.0.2.1/24"}, update_field="description", endpoint="ip_addresses", ) class TestRole(BaseTest): @pytest.fixture(scope="class") def role(self, api): ret = api.ipam.roles.create(name="test-role", slug="test-role") yield ret ret.delete() @pytest.fixture(scope="class") def init(self, request, role): self._init_helper( request, role, filter_kwargs={"name": "test-role"}, update_field="description", endpoint="roles", ) class TestVlan(BaseTest): @pytest.fixture(scope="class") def vlan(self, api): ret = api.ipam.vlans.create(vid=123, name="test-vlan") yield ret ret.delete() @pytest.fixture(scope="class") def init(self, request, vlan): self._init_helper( request, vlan, filter_kwargs={"name": "test-vlan"}, update_field="description", endpoint="vlans", ) class TestVRF(BaseTest): @pytest.fixture(scope="class") def vrf(self, api): ret = api.ipam.vrfs.create(name="test-vrf", rd="192.0.2.1:1234") yield ret ret.delete() @pytest.fixture(scope="class") def init(self, request, vrf): self._init_helper( request, vrf, filter_kwargs={"name": "test-vrf"}, update_field="description", endpoint="vrfs", ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/test_api.py0000644000175100001730000000553014344673022016323 0ustar00runnerdockerimport unittest from unittest.mock import patch import pynetbox from .util import Response host = "http://localhost:8000" def_kwargs = { "token": "abc123", "private_key_file": "tests/fixtures/api/get_session_key.json", } # Keys are app names, values are arbitrarily selected endpoints # We use dcim and ipam since they have unique app classes # and circuits because it does not. We don't add other apps/endpoints # beyond 'circuits' as they all use the same code as each other endpoints = { "dcim": "devices", "ipam": "prefixes", "circuits": "circuits", } class ApiTestCase(unittest.TestCase): @patch( "requests.sessions.Session.post", return_value=Response(fixture="api/get_session_key.json"), ) def test_get(self, *_): api = pynetbox.api(host, **def_kwargs) self.assertTrue(api) @patch( "requests.sessions.Session.post", return_value=Response(fixture="api/get_session_key.json"), ) def test_sanitize_url(self, *_): api = pynetbox.api("http://localhost:8000/", **def_kwargs) self.assertTrue(api) self.assertEqual(api.base_url, "http://localhost:8000/api") class ApiVersionTestCase(unittest.TestCase): class ResponseHeadersWithVersion: headers = {"API-Version": "1.999"} ok = True @patch( "requests.sessions.Session.get", return_value=ResponseHeadersWithVersion(), ) def test_api_version(self, *_): api = pynetbox.api( host, ) self.assertEqual(api.version, "1.999") class ResponseHeadersWithoutVersion: headers = {} ok = True @patch( "requests.sessions.Session.get", return_value=ResponseHeadersWithoutVersion(), ) def test_api_version_not_found(self, *_): api = pynetbox.api( host, ) self.assertEqual(api.version, "") class ApiStatusTestCase(unittest.TestCase): class ResponseWithStatus: ok = True def json(self): return { "netbox-version": "0.9.9", } @patch( "requests.sessions.Session.get", return_value=ResponseWithStatus(), ) def test_api_status(self, *_): api = pynetbox.api( host, ) self.assertEqual(api.status()["netbox-version"], "0.9.9") class ApiCreateTokenTestCase(unittest.TestCase): @patch( "requests.sessions.Session.post", return_value=Response(fixture="api/token_provision.json"), ) def test_create_token(self, *_): api = pynetbox.api(host) token = api.create_token("user", "pass") self.assertTrue(isinstance(token, pynetbox.core.response.Record)) self.assertEqual(token.key, "1234567890123456789012345678901234567890") self.assertEqual(api.token, "1234567890123456789012345678901234567890") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/test_app.py0000644000175100001730000000500514344673022016327 0ustar00runnerdockerimport unittest from unittest.mock import patch import pynetbox host = "http://localhost:8000" def_kwargs = { "token": "abc123", } class AppCustomChoicesTestCase(unittest.TestCase): @patch( "pynetbox.core.query.Request.get", return_value={ "Testfield1": {"TF1_1": 1, "TF1_2": 2}, "Testfield2": {"TF2_1": 3, "TF2_2": 4}, }, ) def test_custom_choices(self, *_): api = pynetbox.api(host, **def_kwargs) choices = api.extras.custom_choices() self.assertEqual(len(choices), 2) self.assertEqual(sorted(choices.keys()), ["Testfield1", "Testfield2"]) class AppConfigTestCase(unittest.TestCase): @patch( "pynetbox.core.query.Request.get", return_value={ "tables": { "DeviceTable": { "columns": [ "name", "status", "tenant", "tags", ], }, }, }, ) def test_config(self, *_): api = pynetbox.api(host, **def_kwargs) config = api.users.config() self.assertEqual(sorted(config.keys()), ["tables"]) self.assertEqual( sorted(config["tables"]["DeviceTable"]["columns"]), ["name", "status", "tags", "tenant"], ) class PluginAppCustomChoicesTestCase(unittest.TestCase): @patch( "pynetbox.core.query.Request.get", return_value={ "Testfield1": {"TF1_1": 1, "TF1_2": 2}, "Testfield2": {"TF2_1": 3, "TF2_2": 4}, }, ) def test_custom_choices(self, *_): api = pynetbox.api(host, **def_kwargs) choices = api.plugins.test_plugin.custom_choices() self.assertEqual(len(choices), 2) self.assertEqual(sorted(choices.keys()), ["Testfield1", "Testfield2"]) @patch( "pynetbox.core.query.Request.get", return_value=[ { "name": "test_plugin", "package": "netbox_test_plugin", } ], ) def test_installed_plugins(self, *_): api = pynetbox.api(host, **def_kwargs) plugins = api.plugins.installed_plugins() self.assertEqual(len(plugins), 1) self.assertEqual(plugins[0]["name"], "test_plugin") def test_plugin_app_name(self, *_): api = pynetbox.api(host, **def_kwargs) test_plugin = api.plugins.test_plugin self.assertEqual(test_plugin.name, "plugins/test-plugin") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/test_circuits.py0000644000175100001730000000625114344673022017400 0ustar00runnerdockerimport unittest from unittest.mock import patch from .util import Response import pynetbox api = pynetbox.api( "http://localhost:8000", ) nb = api.circuits HEADERS = {"accept": "application/json;"} class Generic: class Tests(unittest.TestCase): name = "" ret = pynetbox.core.response.Record app = "circuits" def test_get_all(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb, self.name).all()) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"limit": 0}, json=None, headers=HEADERS, ) def test_filter(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb, self.name).filter(name="test")) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"name": "test", "limit": 0}, json=None, headers=HEADERS, ) def test_get(self): with patch( "requests.sessions.Session.get", return_value=Response( fixture="{}/{}.json".format(self.app, self.name[:-1]) ), ) as mock: ret = getattr(nb, self.name).get(1) self.assertTrue(ret) self.assertTrue(isinstance(ret, self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/1/".format( self.app, self.name.replace("_", "-") ), params={}, json=None, headers=HEADERS, ) class CircuitsTestCase(Generic.Tests): name = "circuits" @patch( "requests.sessions.Session.get", return_value=Response(fixture="circuits/circuit.json"), ) def test_repr(self, _): test = nb.circuits.get(1) self.assertEqual(str(test), "123456") class ProviderTestCase(Generic.Tests): name = "providers" class CircuitTypeTestCase(Generic.Tests): name = "circuit_types" class CircuitTerminationsTestCase(Generic.Tests): name = "circuit_terminations" @patch( "requests.sessions.Session.get", return_value=Response(fixture="circuits/circuit_termination.json"), ) def test_repr(self, _): test = nb.circuit_terminations.get(1) self.assertEqual(str(test), "123456") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/test_tenancy.py0000644000175100001730000000505014344673022017210 0ustar00runnerdockerimport unittest from unittest.mock import patch import pynetbox from .util import Response api = pynetbox.api( "http://localhost:8000", ) nb = api.tenancy HEADERS = {"accept": "application/json;"} class Generic: class Tests(unittest.TestCase): name = "" ret = pynetbox.core.response.Record app = "tenancy" def test_get_all(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb, self.name).all()) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"limit": 0}, json=None, headers=HEADERS, ) def test_filter(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb, self.name).filter(name="test")) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"name": "test", "limit": 0}, json=None, headers=HEADERS, ) def test_get(self): with patch( "requests.sessions.Session.get", return_value=Response( fixture="{}/{}.json".format(self.app, self.name[:-1]) ), ) as mock: ret = getattr(nb, self.name).get(1) self.assertTrue(ret) self.assertTrue(isinstance(ret, self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/1/".format( self.app, self.name.replace("_", "-") ), params={}, json=None, headers=HEADERS, ) class TenantsTestCase(Generic.Tests): name = "tenants" class TenantGroupsTestCase(Generic.Tests): name = "tenant_groups" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/test_users.py0000644000175100001730000000745514344673022016723 0ustar00runnerdockerimport unittest from unittest.mock import patch import pynetbox from .util import Response api = pynetbox.api( "http://localhost:8000", ) nb = api.users HEADERS = {"accept": "application/json;"} class Generic: class Tests(unittest.TestCase): name = "" ret = pynetbox.core.response.Record app = "users" def test_get_all(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb, self.name).all()) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"limit": 0}, json=None, headers=HEADERS, ) def test_filter(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb, self.name).filter(name="test")) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"name": "test", "limit": 0}, json=None, headers=HEADERS, ) def test_get(self): with patch( "requests.sessions.Session.get", return_value=Response( fixture="{}/{}.json".format(self.app, self.name[:-1]) ), ) as mock: ret = getattr(nb, self.name).get(1) self.assertTrue(ret) self.assertTrue(isinstance(ret, self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/1/".format( self.app, self.name.replace("_", "-") ), params={}, json=None, headers=HEADERS, ) class UsersTestCase(Generic.Tests): name = "users" @patch( "requests.sessions.Session.get", return_value=Response(fixture="users/user.json"), ) def test_repr(self, _): test = nb.users.get(1) self.assertEqual(type(test), pynetbox.models.users.Users) self.assertEqual(str(test), "user1") class GroupsTestCase(Generic.Tests): name = "groups" class PermissionsTestCase(Generic.Tests): name = "permissions" @patch( "requests.sessions.Session.get", return_value=Response(fixture="users/permission.json"), ) def test_username(self, _): permission = nb.permissions.get(1) self.assertEqual(len(permission.users), 1) user = permission.users[0] self.assertEqual(str(user), "user1") class UnknownModelTestCase(unittest.TestCase): """This test validates that an unknown model is returned as Record object and that the __str__() method correctly uses the 'display' field of the object (introduced as a standard field in NetBox 2.11.0). """ @patch( "requests.sessions.Session.get", return_value=Response(fixture="users/unknown_model.json"), ) def test_unknown_model(self, _): unknown_obj = nb.unknown_model.get(1) self.assertEqual(type(unknown_obj), pynetbox.core.response.Record) self.assertEqual(str(unknown_obj), "Unknown object") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/test_virtualization.py0000644000175100001730000000542314344673022020637 0ustar00runnerdockerimport unittest from unittest.mock import patch from .util import Response import pynetbox api = pynetbox.api( "http://localhost:8000", ) nb = api.virtualization HEADERS = {"accept": "application/json;"} class Generic: class Tests(unittest.TestCase): name = "" ret = pynetbox.core.response.Record app = "virtualization" def test_get_all(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb, self.name).all()) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"limit": 0}, json=None, headers=HEADERS, ) def test_filter(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb, self.name).filter(name="test")) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"name": "test", "limit": 0}, json=None, headers=HEADERS, ) def test_get(self): with patch( "requests.sessions.Session.get", return_value=Response( fixture="{}/{}.json".format(self.app, self.name[:-1]) ), ) as mock: ret = getattr(nb, self.name).get(1) self.assertTrue(ret) self.assertTrue(isinstance(ret, self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/1/".format( self.app, self.name.replace("_", "-") ), params={}, json=None, headers=HEADERS, ) class ClusterTypesTestCase(Generic.Tests): name = "cluster_types" class ClusterGroupsTestCase(Generic.Tests): name = "cluster_groups" class ClustersTestCase(Generic.Tests): name = "clusters" class VirtualMachinesTestCase(Generic.Tests): name = "virtual_machines" class InterfacesTestCase(Generic.Tests): name = "interfaces" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/test_wireless.py0000644000175100001730000000553414344673022017413 0ustar00runnerdockerimport unittest from unittest.mock import patch import pynetbox from .util import Response api = pynetbox.api("http://localhost:8000") nb_app = api.wireless HEADERS = {"accept": "application/json;"} class Generic: class Tests(unittest.TestCase): name = "" ret = pynetbox.core.response.Record app = "wireless" def test_get_all(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb_app, self.name).all()) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"limit": 0}, json=None, headers=HEADERS, ) def test_filter(self): with patch( "requests.sessions.Session.get", return_value=Response(fixture="{}/{}.json".format(self.app, self.name)), ) as mock: ret = list(getattr(nb_app, self.name).filter(name="test")) self.assertTrue(ret) self.assertTrue(isinstance(ret[0], self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/".format( self.app, self.name.replace("_", "-") ), params={"name": "test", "limit": 0}, json=None, headers=HEADERS, ) def test_get(self): with patch( "requests.sessions.Session.get", return_value=Response( fixture="{}/{}.json".format(self.app, self.name[:-1]) ), ) as mock: ret = getattr(nb_app, self.name).get(1) self.assertTrue(ret) self.assertTrue(isinstance(ret, self.ret)) mock.assert_called_with( "http://localhost:8000/api/{}/{}/1/".format( self.app, self.name.replace("_", "-") ), params={}, json=None, headers=HEADERS, ) class WirelessLansTestCase(Generic.Tests): name = "wireless_lans" @patch( "requests.sessions.Session.get", return_value=Response(fixture="wireless/wireless_lan.json"), ) def test_repr(self, _): wireless_lan_obj = nb_app.wireless_lans.get(1) self.assertEqual(type(wireless_lan_obj), pynetbox.models.wireless.WirelessLans) self.assertEqual(str(wireless_lan_obj), "SSID 1") ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1670608413.226451 pynetbox-7.0.0/tests/unit/0000755000175100001730000000000014344673035015121 5ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/unit/__init__.py0000644000175100001730000000000014344673022017214 0ustar00runnerdocker././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/unit/test_detailendpoint.py0000644000175100001730000000505414344673022021535 0ustar00runnerdockerimport unittest from unittest.mock import patch import pynetbox nb = pynetbox.api("http://localhost:8000") class DetailEndpointTestCase(unittest.TestCase): def test_detail_endpoint_create_single(self): # Prefixes with patch( "pynetbox.core.query.Request._make_call", return_value={"id": 123, "prefix": "1.2.3.0/24"}, ): prefix_obj = nb.ipam.prefixes.get(123) self.assertEqual(prefix_obj.prefix, "1.2.3.0/24") with patch( "pynetbox.core.query.Request._make_call", return_value={"address": "1.2.3.1/24"}, ): ip_obj = prefix_obj.available_ips.create() self.assertEqual(ip_obj.address, "1.2.3.1/24") # IP Ranges with patch( "pynetbox.core.query.Request._make_call", return_value={"id": 321, "display": "1.2.4.1-254/24"}, ): ip_range_obj = nb.ipam.ip_ranges.get(321) self.assertEqual(ip_range_obj.display, "1.2.4.1-254/24") with patch( "pynetbox.core.query.Request._make_call", return_value={"address": "1.2.4.2/24"}, ): ip_obj = ip_range_obj.available_ips.create() self.assertEqual(ip_obj.address, "1.2.4.2/24") def test_detail_endpoint_create_list(self): # Prefixes with patch( "pynetbox.core.query.Request._make_call", return_value={"id": 123, "prefix": "1.2.3.0/24"}, ): prefix_obj = nb.ipam.prefixes.get(123) self.assertEqual(prefix_obj.prefix, "1.2.3.0/24") with patch( "pynetbox.core.query.Request._make_call", return_value=[{"address": "1.2.3.1/24"}, {"address": "1.2.3.2/24"}], ): ip_list = prefix_obj.available_ips.create([{} for _ in range(2)]) self.assertTrue(isinstance(ip_list, list)) self.assertEqual(len(ip_list), 2) # IP Ranges with patch( "pynetbox.core.query.Request._make_call", return_value={"id": 321, "display": "1.2.4.1-254/24"}, ): ip_range_obj = nb.ipam.ip_ranges.get(321) self.assertEqual(ip_range_obj.display, "1.2.4.1-254/24") with patch( "pynetbox.core.query.Request._make_call", return_value=[{"address": "1.2.4.2/24"}, {"address": "1.2.4.3/24"}], ): ip_list = ip_range_obj.available_ips.create([{} for _ in range(2)]) self.assertTrue(isinstance(ip_list, list)) self.assertEqual(len(ip_list), 2) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/unit/test_endpoint.py0000644000175100001730000001553214344673022020354 0ustar00runnerdockerimport unittest from unittest.mock import patch, Mock from pynetbox.core.endpoint import Endpoint class EndPointTestCase(unittest.TestCase): def test_filter(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") mock.return_value = [{"id": 123}, {"id": 321}] test_obj = Endpoint(api, app, "test") test = test_obj.filter(test="test") self.assertEqual(len(test), 2) def test_filter_invalid_pagination_args(self): api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") with self.assertRaises(ValueError) as _: test_obj.filter(offset=1) def test_all_invalid_pagination_args(self): api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") with self.assertRaises(ValueError) as _: test_obj.all(offset=1) def test_choices(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}, ] } } } } test_obj = Endpoint(api, app, "test") choices = test_obj.choices() self.assertEqual(choices["letter"][1]["display_name"], "B") self.assertEqual(choices["letter"][1]["value"], 2) def test_get_with_filter(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: mock.return_value = [{"id": 123}] api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") test = test_obj.get(name="test") self.assertEqual(test.id, 123) def test_delete_with_ids(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: ids = [1, 3, 5] mock.return_value = True api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") test = test_obj.delete(ids) mock.assert_called_with(verb="delete", data=[{"id": i} for i in ids]) self.assertTrue(test) def test_delete_with_objects(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: from pynetbox.core.response import Record ids = [1, 3, 5] mock.return_value = True api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") objects = [ Record({"id": i, "name": "dummy" + str(i)}, api, test_obj) for i in ids ] test = test_obj.delete(objects) mock.assert_called_with(verb="delete", data=[{"id": i} for i in ids]) self.assertTrue(test) def test_delete_with_recordset(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: from pynetbox.core.response import RecordSet ids = [1, 3, 5] class FakeRequest: def get(self): return iter([{"id": i, "name": "dummy" + str(i)} for i in ids]) mock.return_value = True api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") recordset = RecordSet(test_obj, FakeRequest()) test = test_obj.delete(recordset) mock.assert_called_with(verb="delete", data=[{"id": i} for i in ids]) self.assertTrue(test) def test_get_greater_than_one(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: mock.return_value = [{"id": 123}, {"id": 321}] api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") with self.assertRaises(ValueError) as _: test_obj.get(name="test") def test_get_no_results(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: mock.return_value = [] api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") test = test_obj.get(name="test") self.assertIsNone(test) def test_bulk_update_records(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: from pynetbox.core.response import Record ids = [1, 3, 5] mock.return_value = True api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") objects = [ Record( {"id": i, "name": "dummy" + str(i), "unchanged": "yes"}, api, test_obj, ) for i in ids ] for o in objects: o.name = "fluffy" + str(o.id) mock.return_value = [o.serialize() for o in objects] test = test_obj.update(objects) mock.assert_called_with( verb="patch", data=[{"id": i, "name": "fluffy" + str(i)} for i in ids] ) self.assertTrue(test) def test_bulk_update_json(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: ids = [1, 3, 5] changes = [{"id": i, "name": "puffy" + str(i)} for i in ids] mock.return_value = True api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") mock.return_value = changes test_obj = Endpoint(api, app, "test") test = test_obj.update(changes) mock.assert_called_with(verb="patch", data=changes) self.assertTrue(test) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/unit/test_extras.py0000644000175100001730000000235414344673022020040 0ustar00runnerdockerimport unittest from pynetbox.models.extras import ConfigContexts class ExtrasTestCase(unittest.TestCase): def test_config_contexts(self): test_values = { "data": { "test_int": 123, "test_str": "testing", "test_list": [1, 2, 3], } } test = ConfigContexts(test_values, None, None) self.assertTrue(test) def test_config_contexts_diff_str(self): test_values = { "data": { "test_int": 123, "test_str": "testing", "test_list": [1, 2, 3], "test_dict": {"foo": "bar"}, } } test = ConfigContexts(test_values, None, None) test.data["test_str"] = "bar" self.assertEqual(test._diff(), {"data"}) def test_config_contexts_diff_dict(self): test_values = { "data": { "test_int": 123, "test_str": "testing", "test_list": [1, 2, 3], "test_dict": {"foo": "bar"}, } } test = ConfigContexts(test_values, None, None) test.data["test_dict"].update({"bar": "foo"}) self.assertEqual(test._diff(), {"data"}) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/unit/test_query.py0000644000175100001730000000554314344673022017702 0ustar00runnerdockerimport unittest from unittest.mock import Mock, call from pynetbox.core.query import Request class RequestTestCase(unittest.TestCase): def test_get_count(self): test_obj = Request( http_session=Mock(), base="http://localhost:8001/api/dcim/devices", filters={"q": "abcd"}, ) test_obj.http_session.get.return_value.json.return_value = { "count": 42, "next": "http://localhost:8001/api/dcim/devices?limit=1&offset=1&q=abcd", "previous": False, "results": [], } expected = call( "http://localhost:8001/api/dcim/devices/", params={"q": "abcd", "limit": 1}, headers={"accept": "application/json;"}, ) test_obj.http_session.get.ok = True test = test_obj.get_count() self.assertEqual(test, 42) test_obj.http_session.get.assert_called_with( "http://localhost:8001/api/dcim/devices/", params={"q": "abcd", "limit": 1}, headers={"accept": "application/json;"}, json=None, ) def test_get_count_no_filters(self): test_obj = Request( http_session=Mock(), base="http://localhost:8001/api/dcim/devices", ) test_obj.http_session.get.return_value.json.return_value = { "count": 42, "next": "http://localhost:8001/api/dcim/devices?limit=1&offset=1", "previous": False, "results": [], } test_obj.http_session.get.ok = True test = test_obj.get_count() self.assertEqual(test, 42) test_obj.http_session.get.assert_called_with( "http://localhost:8001/api/dcim/devices/", params={"limit": 1}, headers={"accept": "application/json;"}, json=None, ) def test_get_manual_pagination(self): test_obj = Request( http_session=Mock(), base="http://localhost:8001/api/dcim/devices", limit=10, offset=20, ) test_obj.http_session.get.return_value.json.return_value = { "count": 4, "next": "http://localhost:8001/api/dcim/devices?limit=10&offset=30", "previous": False, "results": [1, 2, 3, 4], } expected = call( "http://localhost:8001/api/dcim/devices/", params={"offset": 20, "limit": 10}, headers={"accept": "application/json;"}, ) test_obj.http_session.get.ok = True generator = test_obj.get() self.assertEqual(len(list(generator)), 4) test_obj.http_session.get.assert_called_with( "http://localhost:8001/api/dcim/devices/", params={"offset": 20, "limit": 10}, headers={"accept": "application/json;"}, json=None, ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/unit/test_request.py0000644000175100001730000000066014344673022020220 0ustar00runnerdockerimport unittest from unittest.mock import Mock from pynetbox.core.query import Request class RequestTestCase(unittest.TestCase): def test_get_openapi(self): test = Request("http://localhost:8080/api", Mock()) test.get_openapi() test.http_session.get.assert_called_with( "http://localhost:8080/api/docs/?format=openapi", headers={"Content-Type": "application/json;"}, ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/unit/test_response.py0000644000175100001730000003131014344673022020362 0ustar00runnerdockerimport unittest from unittest.mock import patch, Mock from pynetbox.core.response import Record, RecordSet from pynetbox.core.endpoint import Endpoint class RecordTestCase(unittest.TestCase): def test_attribute_access(self): test_values = { "id": 123, "units": 12, "nested_dict": {"id": 222, "name": "bar"}, "int_list": [123, 321, 231], } test_obj = Record(test_values, None, None) self.assertEqual(test_obj.id, 123) self.assertEqual(test_obj.units, 12) self.assertEqual(test_obj.nested_dict.name, "bar") self.assertEqual(test_obj.int_list[1], 321) with self.assertRaises(AttributeError) as _: test_obj.nothing def test_dict_access(self): test_values = { "id": 123, "units": 12, "nested_dict": {"id": 222, "name": "bar"}, "int_list": [123, 321, 231], } test_obj = Record(test_values, None, None) self.assertEqual(test_obj["id"], 123) self.assertEqual(test_obj["units"], 12) self.assertEqual(test_obj["nested_dict"]["name"], "bar") self.assertEqual(test_obj["int_list"][1], 321) with self.assertRaises(KeyError) as _: test_obj["nothing"] def test_serialize_list_of_records(self): test_values = { "id": 123, "tagged_vlans": [ { "id": 1, "url": "http://localhost:8000/api/ipam/vlans/1/", "vid": 1, "name": "test1", "display_name": "test1", }, { "id": 2, "url": "http://localhost:8000/api/ipam/vlans/2/", "vid": 2, "name": "test 2", "display_name": "test2", }, ], } test_obj = Record(test_values, Mock(base_url="test"), None) test = test_obj.serialize() self.assertEqual(test["tagged_vlans"], [1, 2]) def test_serialize_list_of_ints(self): test_values = {"id": 123, "units": [12]} test_obj = Record(test_values, None, None) test = test_obj.serialize() self.assertEqual(test["units"], [12]) def test_serialize_string_tag_set(self): test_values = {"id": 123, "tags": ["foo", "bar", "foo"]} test = Record(test_values, None, None).serialize() self.assertEqual(len(test["tags"]), 2) def test_serialize_dict_tag_set(self): test_values = { "id": 123, "tags": [ { "id": 1, "name": "foo", }, { "id": 2, "name": "bar", }, { "id": 3, "name": "baz", }, ], } test = Record(test_values, None, None).serialize() self.assertEqual(len(test["tags"]), 3) def test_diff(self): test_values = { "id": 123, "custom_fields": {"foo": "bar"}, "string_field": "foobar", "int_field": 1, "nested_dict": {"id": 222, "name": "bar"}, "tags": ["foo", "bar"], "int_list": [123, 321, 231], "local_context_data": {"data": ["one"]}, } test = Record(test_values, None, None) test.tags.append("baz") test.nested_dict = 1 test.string_field = "foobaz" test.local_context_data["data"].append("two") self.assertEqual( test._diff(), {"tags", "nested_dict", "string_field", "local_context_data"} ) def test_diff_append_records_list(self): test_values = { "id": 123, "tagged_vlans": [ { "id": 1, "url": "http://localhost:8000/api/ipam/vlans/1/", "vid": 1, "name": "test1", "display_name": "test1", } ], } test_obj = Record(test_values, Mock(base_url="test"), None) test_obj.tagged_vlans.append(1) test = test_obj._diff() self.assertFalse(test) def test_dict(self): test_values = { "id": 123, "custom_fields": {"foo": "bar"}, "string_field": "foobar", "int_field": 1, "nested_dict": {"id": 222, "name": "bar"}, "tags": ["foo", "bar"], "int_list": [123, 321, 231], "empty_list": [], "record_list": [ { "id": 123, "name": "Test", "str_attr": "foo", "int_attr": 123, "custom_fields": {"foo": "bar"}, "tags": ["foo", "bar"], }, { "id": 321, "name": "Test 1", "str_attr": "bar", "int_attr": 321, "custom_fields": {"foo": "bar"}, "tags": ["foo", "bar"], }, ], } test = Record(test_values, None, None) self.assertEqual(dict(test), test_values) def test_choices_idempotence_prev27(self): test_values = { "id": 123, "choices_test": { "value": 1, "label": "test", }, } test = Record(test_values, None, None) test.choices_test = 1 self.assertFalse(test._diff()) def test_choices_idempotence_v27(self): test_values = { "id": 123, "choices_test": { "value": "test", "label": "test", "id": 1, }, } test = Record(test_values, None, None) test.choices_test = "test" self.assertFalse(test._diff()) def test_choices_idempotence_v28(self): test_values = { "id": 123, "choices_test": { "value": "test", "label": "test", }, } test = Record(test_values, None, None) test.choices_test = "test" self.assertFalse(test._diff()) def test_hash(self): endpoint = Mock() endpoint.name = "test-endpoint" test = Record({}, None, endpoint) self.assertIsInstance(hash(test), int) def test_hash_diff(self): endpoint1 = Mock() endpoint1.name = "test-endpoint" endpoint2 = Mock() endpoint2.name = "test-endpoint" test1 = Record({}, None, endpoint1) test1.id = 1 test2 = Record({}, None, endpoint2) test2.id = 2 self.assertNotEqual(hash(test1), hash(test2)) def test_compare(self): endpoint1 = Mock() endpoint1.name = "test-endpoint" endpoint2 = Mock() endpoint2.name = "test-endpoint" test1 = Record({}, None, endpoint1) test1.id = 1 test2 = Record({}, None, endpoint2) test2.id = 1 self.assertEqual(test1, test2) def test_nested_write(self): app = Mock() app.token = "abc123" app.base_url = "http://localhost:8080/api" endpoint = Mock() endpoint.name = "test-endpoint" test = Record( { "id": 123, "name": "test", "child": { "id": 321, "name": "test123", "url": "http://localhost:8080/api/test-app/test-endpoint/321/", }, }, app, endpoint, ) test.child.name = "test321" test.child.save() self.assertEqual( app.http_session.patch.call_args[0][0], "http://localhost:8080/api/test-app/test-endpoint/321/", ) def test_nested_write_with_directory_in_base_url(self): app = Mock() app.token = "abc123" app.base_url = "http://localhost:8080/testing/api" endpoint = Mock() endpoint.name = "test-endpoint" test = Record( { "id": 123, "name": "test", "child": { "id": 321, "name": "test123", "url": "http://localhost:8080/testing/api/test-app/test-endpoint/321/", }, }, app, endpoint, ) test.child.name = "test321" test.child.save() self.assertEqual( app.http_session.patch.call_args[0][0], "http://localhost:8080/testing/api/test-app/test-endpoint/321/", ) def test_endpoint_from_url(self): api = Mock() api.base_url = "http://localhost:8080/api" test = Record( { "id": 123, "name": "test", "url": "http://localhost:8080/api/test-app/test-endpoint/1/", }, api, None, ) ret = test._endpoint_from_url(test.url) self.assertEqual(ret.name, "test-endpoint") def test_endpoint_from_url_with_directory_in_base_url(self): api = Mock() api.base_url = "http://localhost:8080/testing/api" test = Record( { "id": 123, "name": "test", "url": "http://localhost:8080/testing/api/test-app/test-endpoint/1/", }, api, None, ) ret = test._endpoint_from_url(test.url) self.assertEqual(ret.name, "test-endpoint") def test_endpoint_from_url_with_plugins(self): api = Mock() api.base_url = "http://localhost:8080/api" test = Record( { "id": 123, "name": "test", "url": "http://localhost:8080/api/plugins/test-app/test-endpoint/1/", }, api, None, ) ret = test._endpoint_from_url(test.url) self.assertEqual(ret.name, "test-endpoint") def test_endpoint_from_url_with_plugins_and_directory_in_base_url(self): api = Mock() api.base_url = "http://localhost:8080/testing/api" test = Record( { "id": 123, "name": "test", "url": "http://localhost:8080/testing/api/plugins/test-app/test-endpoint/1/", }, api, None, ) ret = test._endpoint_from_url(test.url) self.assertEqual(ret.name, "test-endpoint") def test_serialize_tag_list_order(self): """Add tests to ensure we're preserving tag order This test could still give false-negatives, but making the tag list longer helps mitigate that. """ test_tags = [ "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", ] test = Record({"id": 123, "tags": test_tags}, None, None).serialize() self.assertEqual(test["tags"], test_tags) class RecordSetTestCase(unittest.TestCase): ids = [1, 3, 5] @classmethod def init_recordset(cls): data = [ {"id": i, "name": "dummy" + str(i), "status": "active"} for i in cls.ids ] api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") class FakeRequest: def get(self): return iter(data) def patch(self): return iter(data) return RecordSet(Endpoint(api, app, "test"), FakeRequest()) def test_delete(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: mock.return_value = True test_obj = RecordSetTestCase.init_recordset() test = test_obj.delete() mock.assert_called_with( verb="delete", data=[{"id": i} for i in RecordSetTestCase.ids] ) self.assertTrue(test) def test_update(self): with patch( "pynetbox.core.query.Request._make_call", return_value=Mock() ) as mock: mock.return_value = [ {"id": i, "name": "dummy" + str(i), "status": "offline"} for i in RecordSetTestCase.ids ] test_obj = RecordSetTestCase.init_recordset() test = test_obj.update(status="offline") mock.assert_called_with( verb="patch", data=[{"id": i, "status": "offline"} for i in RecordSetTestCase.ids], ) self.assertTrue(test) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1670608402.0 pynetbox-7.0.0/tests/util.py0000644000175100001730000000067114344673022015471 0ustar00runnerdockerimport json class Response: def __init__(self, fixture=None, status_code=200, ok=True, content=None): self.status_code = status_code self.content = json.dumps(content) if content else self.load_fixture(fixture) self.ok = ok def load_fixture(self, path): with open("tests/fixtures/{}".format(path), "r") as f: return f.read() def json(self): return json.loads(self.content)