diff --git a/README.md b/README.md index 34dd5af..75c0d77 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,11 @@ This plugin requries one environment variable: ```sh STATUS_GO_CANARY_PATH= ``` + +# API + +The plugin exposes the standard check API under: +``` +/plugins/cabot_check_status_go/api/status_go_checks/ +``` +Which accepts the standard `GET`/`POST`/`OPTIONS` methods. diff --git a/cabot_check_status_go/models.py b/cabot_check_status_go/models.py index 123211d..1be27c6 100644 --- a/cabot_check_status_go/models.py +++ b/cabot_check_status_go/models.py @@ -1,5 +1,4 @@ import socket -import logging import subprocess from os import path from os import environ as env diff --git a/cabot_check_status_go/urls.py b/cabot_check_status_go/urls.py index 60b1e5a..dec3454 100644 --- a/cabot_check_status_go/urls.py +++ b/cabot_check_status_go/urls.py @@ -1,6 +1,19 @@ -from django.conf.urls import url +from django.conf.urls import include, url +from rest_framework.routers import DefaultRouter + +from cabot.rest_urls import create_viewset, status_check_fields from .views import (StatusGoCheckCreateView, StatusGoCheckUpdateView, duplicate_check) +from .models import StatusGoStatusCheck + +api_router = DefaultRouter() +api_router.register(r'status_go_checks', create_viewset( + arg_model=StatusGoStatusCheck, + arg_fields=status_check_fields + ( + 'node_type', + 'enode', + ), +)) urlpatterns = [ @@ -14,6 +27,7 @@ urlpatterns = [ url(r'^statusgocheck/duplicate/(?P\d+)/', view=duplicate_check, - name='duplicate-status-go-check') + name='duplicate-status-go-check'), + url(r'^api/', include(api_router.urls)), ]