mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-09 10:53:50 +02:00
cleanup
This commit is contained in:
@@ -386,14 +386,14 @@ A complete date & time. Returns a `datetime.datetime` object.
|
||||
|
||||
## Uploading Scripts via the API
|
||||
|
||||
Script modules can be uploaded to NetBox via the REST API by sending a `multipart/form-data` POST request to `/api/extras/script-modules/`. The caller must have the `extras.add_scriptmodule` and `core.add_managedfile` permissions.
|
||||
Script modules can be uploaded to NetBox via the REST API by sending a `multipart/form-data` POST request to `/api/extras/script-upload/`. The caller must have the `extras.add_scriptmodule` and `core.add_managedfile` permissions.
|
||||
|
||||
```no-highlight
|
||||
curl -X POST \
|
||||
-H "Authorization: Token $TOKEN" \
|
||||
-H "Accept: application/json; indent=4" \
|
||||
-F "upload_file=@/path/to/myscript.py" \
|
||||
http://netbox/api/extras/script-modules/
|
||||
http://netbox/api/extras/script-upload/
|
||||
```
|
||||
|
||||
Alternatively, a script module can be linked to an existing data source and data file instead of uploading a file directly:
|
||||
@@ -403,7 +403,7 @@ curl -X POST \
|
||||
-H "Authorization: Token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json; indent=4" \
|
||||
http://netbox/api/extras/script-modules/ \
|
||||
http://netbox/api/extras/script-upload/ \
|
||||
--data '{"data_source": 1, "data_file": 42}'
|
||||
```
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ router.register('journal-entries', views.JournalEntryViewSet)
|
||||
router.register('config-contexts', views.ConfigContextViewSet)
|
||||
router.register('config-context-profiles', views.ConfigContextProfileViewSet)
|
||||
router.register('config-templates', views.ConfigTemplateViewSet)
|
||||
router.register('script-modules', views.ScriptModuleViewSet)
|
||||
router.register('script-upload', views.ScriptModuleViewSet)
|
||||
router.register('scripts', views.ScriptViewSet, basename='script')
|
||||
|
||||
app_name = 'extras-api'
|
||||
|
||||
@@ -1419,7 +1419,7 @@ class ScriptModuleTest(APITestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.url_list = reverse('extras-api:scriptmodule-list')
|
||||
self.url_list = reverse('extras-api:scriptmodule-list') # /api/extras/script-upload/
|
||||
|
||||
def test_upload_script_module_without_permission(self):
|
||||
script_content = b"from extras.scripts import Script\nclass TestScript(Script):\n pass\n"
|
||||
|
||||
Reference in New Issue
Block a user