diff --git a/.github/ISSUE_TEMPLATE/1-bug-report.yml b/.github/ISSUE_TEMPLATE/1-bug-report.yml deleted file mode 100644 index 279f3a9..0000000 --- a/.github/ISSUE_TEMPLATE/1-bug-report.yml +++ /dev/null @@ -1,50 +0,0 @@ ---- -name: 🐞 Bug Report -description: Report a Reproducible Bug in the Current Release of this NetBox Plugin -labels: [ "type: bug" ] -assignees: "kprince28" -body: - - type: markdown - attributes: - value: > - **Note:** This form is exclusively for reporting _reproducible bugs_ in the current NetBox plugin installation. - - - type: input - attributes: - label: NetBox Version - description: Indicate the version of NetBox you are currently running. - placeholder: v3.6.9 - validations: - required: true - - - type: input - attributes: - label: NetBox Plugin Version - description: Please specify the version of the NetBox plugin you are currently using. - placeholder: v0.2.0 - validations: - required: true - - - type: textarea - attributes: - label: Steps to Reproduce - description: > - When submitting a bug report for the NetBox plugin, it's essential to provide comprehensive step-by-step instructions for reproducing the issue on a clean, empty NetBox installation. These instructions should be clear enough for someone else to follow effortlessly and must encompass the creation of any necessary objects, configuration changes, and a complete accounting of the actions being taken. Remember, the goal is to ensure that the problem can be replicated precisely using the current stable release of the NetBox plugin. - validations: - required: true - - - type: textarea - attributes: - label: Expected Behavior - description: Describe what you expected to happen. - placeholder: A new widget should have been created with the specified attributes. - validations: - required: true - - - type: textarea - attributes: - label: Observed Behavior - description: Describe what actually happened. - placeholder: A TypeError exception was raised - validations: - required: true diff --git a/.github/ISSUE_TEMPLATE/2-feature-request.yml b/.github/ISSUE_TEMPLATE/2-feature-request.yml deleted file mode 100644 index 68e1840..0000000 --- a/.github/ISSUE_TEMPLATE/2-feature-request.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -name: ✨ Feature Request -description: Propose a new feature or enhancement -labels: [ "type: feature" ] -assignees: "kprince28" -body: - - type: markdown - attributes: - value: > - **NOTE:** This form is exclusively for submitting well-considered proposals to expand or refine - NetBox Plugin's functionality. If you're grappling with a problem or still refining your feature idea, - please initiate a discussion instead. - - - type: input - attributes: - label: Current NetBox Version - description: What version of NetBox are you currently running? - placeholder: v3.6.9 - validations: - required: true - - - type: dropdown - attributes: - label: Feature Type - options: - - New Model for Plugin - - Modification to Existing Model - - Addition of a Function - - Removal of a Function - validations: - required: true - - - type: textarea - attributes: - label: Proposed Functionality - description: > - Provide a comprehensive description of the new feature or behavior you are suggesting. Include specific changes - to workflows, data models, and dependencies. The more detailed your proposal, the higher the chance it will be discussed. - Feature requests without a clear implementation plan may be declined. - validations: - required: true - - - type: textarea - attributes: - label: Use Case - description: > - Explain how implementing this functionality would benefit NetBox users, particularly within this plugin's context. - What problem does it address? - validations: - required: true - - - type: textarea - attributes: - label: External Dependencies - description: > - Enumerate any new external libraries or services that this feature would necessitate. - For example, does it require installing a new Python package? (Not all new features introduce dependencies.) diff --git a/.github/ISSUE_TEMPLATE/3-documentation-change.yml b/.github/ISSUE_TEMPLATE/3-documentation-change.yml deleted file mode 100644 index 4a60358..0000000 --- a/.github/ISSUE_TEMPLATE/3-documentation-change.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -name: 📖 Documentation Enhancement -description: Suggest an enhancement, addition, or modification to the NetBox plugin documentation. -labels: [ "type: docs" ] -assignees: "kprince28" -body: - - type: dropdown - attributes: - label: Change Type - description: Specify the nature of your documentation change. - options: - - Addition - - Correction - - Removal - - Cleanup (formatting, typos, etc.) - validations: - required: true - - - type: dropdown - attributes: - label: Documentation Section - description: Indicate the section of the documentation that this change primarily affects. - options: - - Installation Instructions - - Configuration Parameters - - Functionality/Features - - Administration/Development - - Other - validations: - required: true - - - type: textarea - attributes: - label: Proposed Changes - description: Please describe the proposed changes and explain their significance or necessity. - validations: - required: true diff --git a/.github/ISSUE_TEMPLATE/4-housekeeping.yml b/.github/ISSUE_TEMPLATE/4-housekeeping.yml deleted file mode 100644 index 2df4a75..0000000 --- a/.github/ISSUE_TEMPLATE/4-housekeeping.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -name: 🏡 Housekeeping -description: A codebase enhancement (for developers' use only) -labels: ["type: maintenance"] -assignees: "kprince28" -body: - - type: markdown - attributes: - value: > - **Important Note:** This template is intended for use by maintainers exclusively. Please refrain from submitting an issue using this template unless you have been specifically requested to do so. - - - type: textarea - attributes: - label: Proposed Changes - description: > - Please provide a detailed description of the new feature or behavior you are proposing. Include any specific modifications to workflows, data models, or the user interface. - validations: - required: true - - - type: textarea - attributes: - label: Justification - description: Please offer a rationale for the proposed changes. - validations: - required: true diff --git a/.github/ISSUE_TEMPLATE/5-deprecation.yml b/.github/ISSUE_TEMPLATE/5-deprecation.yml deleted file mode 100644 index 2404361..0000000 --- a/.github/ISSUE_TEMPLATE/5-deprecation.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -name: ⚠️ Deprecation Notice -description: A deprecation notice for outdated features or behaviors -labels: ["type: deprecated"] -assignees: "kprince28" -body: - - type: markdown - attributes: - value: > - **Important Note:** This template is intended to inform users and developers about the deprecation of certain features or behaviors in the project. If you have questions or need assistance with the transition, please comment on this issue. - - - type: textarea - attributes: - label: Deprecated Feature or Behavior - description: > - Please specify the feature or behavior that is being deprecated. Include relevant details such as the file, function, or component name. - validations: - required: true - - - type: textarea - attributes: - label: Deprecation Details - description: > - Provide information about why this feature or behavior is being deprecated. Explain any alternatives or recommended actions for users or developers to take. - validations: - required: true - - - type: textarea - attributes: - label: Timeline for Deprecation - description: > - Outline the timeline for the deprecation process, including any milestones, dates, or versions when the feature or behavior will be officially deprecated and removed. - validations: - required: true diff --git a/.github/labels.toml b/.github/labels.toml deleted file mode 100644 index b063e45..0000000 --- a/.github/labels.toml +++ /dev/null @@ -1,119 +0,0 @@ -["type: performance"] -color = "6572A4" -name = "type: performance" -description = "" - -["status: abandoned"] -color = "fc9580" -name = "status: abandoned" -description = "It's believed that this issue is no longer important to the requestor and no one else has shown an i" - -["status: accepted"] -color = "d66039" -name = "status: accepted" -description = "It's clear what the subject of the issue is about, and what the resolution should be." - -["status: available"] -color = "fcefa6" -name = "status: available" -description = "No one has claimed responsibility for resolving this issue." - -["status: blocked"] -color = "ffcc9e" -name = "status: blocked" -description = "There is another issue that needs to be resolved first, or a specific person is required to comment" - -["status: completed"] -color = "250077" -name = "status: completed" -description = "Nothing further to be done with this issue." - -["status: in progress"] -color = "f4c9a1" -name = "status: in progress" -description = "This issue is being worked on" - -["status: on hold"] -color = "c8a2f9" -name = "status: on hold" -description = "Similar to blocked, but is assigned to someone" - -["status: review needed"] -color = "e99695" -name = "status: review needed" -description = "The issue has a PR attached to it which needs to be reviewed." - -["type: breaking"] -color = "d6a30c" -name = "type: breaking" -description = "" - -["type: bug"] -color = "d73a4a" -name = "type: bug" -description = "Something isn't working" - -["type: dependencies"] -color = "0366d6" -name = "type: dependencies" -description = "Pull requests that update a dependency file" - -["type: deprecated"] -color = "2e0baa" -name = "type: deprecated" -description = "" - -["type: docs"] -color = "0075ca" -name = "type: docs" -description = "Improvements or additions to documentation" - -["type: duplicate"] -color = "cfd3d7" -name = "type: duplicate" -description = "This issue or pull request already exists" - -["type: feature"] -color = "a2eeef" -name = "type: feature" -description = "New feature or request" - -["type: help wanted"] -color = "008672" -name = "type: help wanted" -description = "Extra attention is needed" - -["type: invalid"] -color = "e4e669" -name = "type: invalid" -description = "This doesn't seem right" - -["type: maintenance"] -color = "c2e0c6" -name = "type: maintenance" -description = "" - -["type: question"] -color = "d876e3" -name = "type: question" -description = "Further information is requested" - -["type: security"] -color = "7dede7" -name = "type: security" -description = "Pull requests that address a security vulnerability" - -["type: tests"] -color = "F25F44" -name = "type: tests" -description = "" - -["type: wontfix"] -color = "ffffff" -name = "type: wontfix" -description = "This will not be worked on" - -["type: ui/ux"] -color = "5319E7" -name = "type: ui/ux" -description = "UI/UX design" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index ea64bec..0000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,43 +0,0 @@ -name-template: "v$RESOLVED_VERSION" -tag-template: "v$RESOLVED_VERSION" -template: | - # What's Changed - $CHANGES -categories: - - title: "Breaking" - label: "type: breaking" - - title: "UI" - label: "type: ui/ux" - - title: "New" - label: "type: feature" - - title: "Security" - label: "type: security" - - title: "Bug Fixes" - label: "type: bug" - - title: "Testing" - label: "type: tests" - - title: "Maintenance" - label: "type: maintenance" - - title: "Performance Improvement" - label: "type: performance" - - title: "Documentation" - label: "type: docs" - - title: "Dependency Updates" - label: "type: dependencies" - -version-resolver: - major: - labels: - - "type: breaking" - minor: - labels: - - "type: feature" - patch: - labels: - - "type: bug" - - "type: maintenance" - - "type: docs" - - "type: dependencies" - - "type: security" - - "type: tests" - - "type: performance" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c982f4b..519a45d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,8 @@ on: - published workflow_dispatch: { } push: + branches: + - '*' tags: - v[0-9]+.[0-9]+.[0-9]+(-[a-zA-Z]+[0-9]+)? pull_request: @@ -16,10 +18,10 @@ on: jobs: pre_commit: name: Run lint rules - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-sh steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1 - name: Set up Python uses: actions/setup-python@v4.7.0 @@ -29,12 +31,49 @@ jobs: - uses: pre-commit/action@v3.0.0 test: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04-sh name: Runs plugin tests steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1 + + - name: Login to Registry + uses: docker/login-action@v3 + with: + registry: registry.tangience.net + username: ${{ secrets.HARBOR_USERNAME }} + password: ${{ secrets.HARBOR_PASSWORD }} - name: Test the image run: ./test.sh + + changelog: + name: "Changelog Generator" + runs-on: ubuntu-22.04-sh + needs: + - test + timeout-minutes: 30 + if: github.event_name == 'release' + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + + - name: "Generate changelog" + uses: charmixer/auto-changelog-action@v1.4 + with: + exclude_labels: "type: skip ci,status: abandoned,type: duplicate,type: question,type: wontfix,type: invalid" + token: ${{ secrets.GIT_TOKEN }} + + - name: Commit and push to dev + uses: EndBug/add-and-commit@v9.1.3 + env: + GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} + with: + add: "CHANGELOG.md" + message: "[skip ci] Updated CHANGELOG.md" + new_branch: dev + push: origin dev --set-upstream + committer_name: GitHub Actions + committer_email: actions@github.com + default_author: github_actions diff --git a/CHANGELOG.md b/CHANGELOG.md index 407c990..dac23e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [Unreleased](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/tree/HEAD) + +[Full Changelog](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/compare/v0.3.2...HEAD) + +**Closed issues:** + +- Syntax Issue [\#48](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/issues/48) +- Form Invalid When Importing Data Types via API Due to Missing "\_init\_time" Field [\#43](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/issues/43) + +## [v0.3.2](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/tree/v0.3.2) (2024-03-11) + +[Full Changelog](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/compare/v0.2.2...v0.3.2) + +**Merged pull requests:** + +- Release v0.3.2 [\#46](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/pull/46) ([kprince28](https://github.com/kprince28)) +- Add the \_init\_time in the form data [\#44](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/pull/44) ([kprince28](https://github.com/kprince28)) + +## [v0.2.2](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/tree/v0.2.2) (2024-03-11) + +[Full Changelog](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/compare/v0.3.1...v0.2.2) + ## [v0.3.1](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/tree/v0.3.1) (2024-03-11) [Full Changelog](https://github.com/Onemind-Services-LLC/netbox-metatype-importer/compare/v0.2.1...v0.3.1) diff --git a/Dockerfile b/Dockerfile index 7fce067..2d858db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG NETBOX_VARIANT=v3.7 +ARG NETBOX_VARIANT=v4.0 FROM netboxcommunity/netbox:${NETBOX_VARIANT} diff --git a/README.md b/README.md index 8018e14..6e9c730 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ To use GraphQL API you need to set GitHub personal access token in plugin settin | 3.5.x | 0.1.x | | 3.6.x | 0.2.x | | 3.7.x | 0.3.x | +| 4.0.x | 0.4.x | ## Installation diff --git a/docker-compose.yml b/docker-compose.yml index 4a1024e..b66dc46 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.4' - services: netbox: build: diff --git a/netbox_metatype_importer/__init__.py b/netbox_metatype_importer/__init__.py index e4d8bc3..29ed146 100644 --- a/netbox_metatype_importer/__init__.py +++ b/netbox_metatype_importer/__init__.py @@ -1,6 +1,6 @@ from importlib.metadata import metadata -from extras.plugins import PluginConfig +from netbox.plugins import PluginConfig metadata = metadata('netbox_metatype_importer') @@ -13,8 +13,8 @@ class NetBoxMetatypeImporterConfig(PluginConfig): author = metadata.get('Author') author_email = metadata.get('Author-email') base_url = "meta-types" - min_version = '3.7.0' - max_version = '3.7.99' + min_version = '4.0.0' + max_version = '4.0.99' default_settings = { 'repo_owner': 'netbox-community', 'repo': 'devicetype-library', diff --git a/netbox_metatype_importer/api/serializers.py b/netbox_metatype_importer/api/serializers.py index 97e1405..390a3d2 100644 --- a/netbox_metatype_importer/api/serializers.py +++ b/netbox_metatype_importer/api/serializers.py @@ -1,9 +1,12 @@ +from netbox_metatype_importer.models import MetaType from rest_framework import serializers - -from ..models import MetaType +from rest_framework.serializers import HyperlinkedIdentityField class MetaTypeSerializer(serializers.ModelSerializer): + url = HyperlinkedIdentityField(view_name="plugins-api:netbox_metatype_importer-api:metatype-detail") + class Meta: model = MetaType fields = "__all__" + brief_fields = ("id", "url", "display", "name", "description") diff --git a/netbox_metatype_importer/api/urls.py b/netbox_metatype_importer/api/urls.py index 8bd075c..f41c657 100644 --- a/netbox_metatype_importer/api/urls.py +++ b/netbox_metatype_importer/api/urls.py @@ -1,17 +1,25 @@ from netbox.api.routers import NetBoxRouter -from . import views +from .views import ( + DeviceTypeListViewSet, + ModuleTypeListViewSet, + MetaDeviceTypeLoadViewSet, + MetaModuleTypeLoadViewSet, + MetaDeviceTypeImportViewSet, + MetaModuleTypeImportViewSet, + MetaTypeRootView, +) router = NetBoxRouter() -router.APIRootView = views.MetaTypeRootView +router.APIRootView = MetaTypeRootView -router.register('device-types', views.DeviceTypeListViewSet, basename='device-types') -router.register('module-types', views.ModuleTypeListViewSet, basename="module-types") +router.register('device-types', DeviceTypeListViewSet, basename='device-types') +router.register('module-types', ModuleTypeListViewSet, basename="module-types") -router.register('device-type-load', views.MetaDeviceTypeLoadViewSet, basename='device-type-load') -router.register('module-type-load', views.MetaModuleTypeLoadViewSet, basename="module-type-load") +router.register('device-type-load', MetaDeviceTypeLoadViewSet, basename='device-type-load') +router.register('module-type-load', MetaModuleTypeLoadViewSet, basename="module-type-load") -router.register('device-type-import', views.MetaDeviceTypeImportViewSet, basename='device-type-import') -router.register('module-type-import', views.MetaModuleTypeImportViewSet, basename="module-type-import") +router.register('device-type-import', MetaDeviceTypeImportViewSet, basename='device-type-import') +router.register('module-type-import', MetaModuleTypeImportViewSet, basename="module-type-import") urlpatterns = router.urls diff --git a/netbox_metatype_importer/api/views.py b/netbox_metatype_importer/api/views.py index 08581dd..744ea3f 100644 --- a/netbox_metatype_importer/api/views.py +++ b/netbox_metatype_importer/api/views.py @@ -6,6 +6,9 @@ from django.db.models import Q from django.shortcuts import reverse from django.utils.text import slugify +from netbox_metatype_importer.filters import MetaTypeFilterSet +from netbox_metatype_importer.forms import MetaTypeFilterForm +from netbox_metatype_importer.graphql.gql import GQLError, GitHubGqlAPI from rest_framework import mixins as drf_mixins, status from rest_framework.response import Response from rest_framework.routers import APIRootView @@ -13,13 +16,10 @@ from dcim import forms from dcim.models import DeviceType, Manufacturer, ModuleType from netbox.api.viewsets import BaseViewSet -from netbox_metatype_importer.filters import MetaTypeFilterSet -from netbox_metatype_importer.forms import MetaTypeFilterForm from utilities.exceptions import AbortTransaction, PermissionsViolation from utilities.forms.bulk_import import BulkImportForm from . import serializers from ..choices import TypeChoices -from ..gql import GQLError, GitHubGqlAPI from ..models import MetaType from ..utils import * diff --git a/netbox_metatype_importer/forms.py b/netbox_metatype_importer/forms.py index 21aee21..61e695e 100644 --- a/netbox_metatype_importer/forms.py +++ b/netbox_metatype_importer/forms.py @@ -1,10 +1,9 @@ from django import forms -from utilities.forms import BootstrapMixin from .models import MetaType -class MetaTypeFilterForm(BootstrapMixin, forms.Form): +class MetaTypeFilterForm(forms.Form): q = forms.CharField(required=False, label='Name') vendor = forms.CharField(required=False, label='Vendor') diff --git a/netbox_metatype_importer/graphql/__init__.py b/netbox_metatype_importer/graphql/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/netbox_metatype_importer/gql.py b/netbox_metatype_importer/graphql/gql.py similarity index 100% rename from netbox_metatype_importer/gql.py rename to netbox_metatype_importer/graphql/gql.py diff --git a/netbox_metatype_importer/navigation.py b/netbox_metatype_importer/navigation.py index 91ad936..484c94a 100644 --- a/netbox_metatype_importer/navigation.py +++ b/netbox_metatype_importer/navigation.py @@ -1,4 +1,4 @@ -from extras.plugins import PluginMenuItem +from netbox.plugins import PluginMenuItem menu_items = ( PluginMenuItem( diff --git a/netbox_metatype_importer/templates/netbox_metatype_importer/metadevicetype_list.html b/netbox_metatype_importer/templates/netbox_metatype_importer/metadevicetype_list.html index d61ad37..5170450 100644 --- a/netbox_metatype_importer/templates/netbox_metatype_importer/metadevicetype_list.html +++ b/netbox_metatype_importer/templates/netbox_metatype_importer/metadevicetype_list.html @@ -22,6 +22,7 @@ {% if perms.netbox_metatype_importer.add_metadevicetype %}