Skip to content

Commit

Permalink
initial REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanovic committed Jan 14, 2019
1 parent c2df79f commit 0a89c9b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 17 deletions.
52 changes: 35 additions & 17 deletions cvat/apps/engine/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,40 @@
from . import views

urlpatterns = [
path('v1', views.api_root), # entry point for API
path('v1/tasks/', None), # POST, GET
path('v1/tasks/<int:tid>', None), # GET, DELETE, PUT
path('v1/tasks/<int:tid>/frames/<int:frame>', None), # GET
path('v1/tasks/<int:tid>/jobs/', None), # GET
path('v1/jobs/<int:jid>', None), # GET, PUT
path('v1/tasks/<int:tid>/annotations/', None), # GET, DELETE, PATCH
path('v1/jobs/<int:jid>/annotations/', None), # GET, DELETE, PATCH
path('v1/users/', None), # GET
path('v1/users/myself', None), # GET
path('v1/exceptions/', None), # POST
path('v1/info/', None), # GET
path('v1/plugins/', None), # GET
path('v1/plugins/<slug:name>/config/', None), # GET, PUT
path('v1/plugins/<slug:name>/requests/', None), # GET, POST
path('v1/plugins/<slug:name>/requests/<int:id>', None), # GET, DELETE

path('create/task', views.create_task), ####
path('get/task/<int:tid>/frame/<int:frame>', views.get_frame), ###
path('check/task/<int:tid>', views.check_task), ####
path('delete/task/<int:tid>', views.delete_task), ####
path('update/task/<int:tid>', views.update_task), ####
path('get/job/<int:jid>', views.get_job), ###
path('get/task/<int:tid>', views.get_task), ####
path('dump/annotation/task/<int:tid>', views.dump_annotation), ###
path('check/annotation/task/<int:tid>', views.check_annotation), ###
path('download/annotation/task/<int:tid>', views.download_annotation), ###
path('save/annotation/job/<int:jid>', views.save_annotation_for_job), ###
path('save/annotation/task/<int:tid>', views.save_annotation_for_task), ###
path('delete/annotation/task/<int:tid>', views.delete_annotation_for_task), ###
path('get/annotation/job/<int:jid>', views.get_annotation), ###
path('get/username', views.get_username), ###
path('save/exception/<int:jid>', views.catch_client_exception), ###
path('save/status/job/<int:jid>', views.save_job_status), ###

path('', views.dispatch_request),
path('create/task', views.create_task),
path('get/task/<int:tid>/frame/<int:frame>', views.get_frame),
path('check/task/<int:tid>', views.check_task),
path('delete/task/<int:tid>', views.delete_task),
path('update/task/<int:tid>', views.update_task),
path('get/job/<int:jid>', views.get_job),
path('get/task/<int:tid>', views.get_task),
path('dump/annotation/task/<int:tid>', views.dump_annotation),
path('check/annotation/task/<int:tid>', views.check_annotation),
path('download/annotation/task/<int:tid>', views.download_annotation),
path('save/annotation/job/<int:jid>', views.save_annotation_for_job),
path('save/annotation/task/<int:tid>', views.save_annotation_for_task),
path('delete/annotation/task/<int:tid>', views.delete_annotation_for_task),
path('get/annotation/job/<int:jid>', views.get_annotation),
path('get/username', views.get_username),
path('save/exception/<int:jid>', views.catch_client_exception),
path('save/status/job/<int:jid>', views.save_job_status),
]
14 changes: 14 additions & 0 deletions cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from rules.contrib.views import permission_required, objectgetter
from django.views.decorators.gzip import gzip_page
from sendfile import sendfile
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework.reverse import reverse


from . import annotation, task, models
from cvat.settings.base import JS_3RDPARTY
Expand All @@ -22,6 +26,16 @@
from .log import slogger, clogger
from cvat.apps.engine.models import StatusChoice

############################# Server REST API

@api_view(['GET'])
def api_root(request, format=None):
return Response({
'users': reverse('user-list', request=request, format=format),
})



############################# High Level server API
@login_required
@permission_required(perm=['engine.job.access'],
Expand Down
4 changes: 4 additions & 0 deletions cvat/requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ python-logstash==0.4.6
django-revproxy==0.9.15
rules==2.0
GitPython==2.1.11
coreapi==2.3.3
django-filter==2.0.0
Markdown==3.0.1
djangorestframework==3.9.0
7 changes: 7 additions & 0 deletions cvat/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ def generate_ssh_keys():
'dj_pagination',
'revproxy',
'rules',
'rest_framework',
]

REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated'
]
}

if 'yes' == os.environ.get('TF_ANNOTATION', 'no'):
INSTALLED_APPS += ['cvat.apps.tf_annotation']

Expand Down

0 comments on commit 0a89c9b

Please sign in to comment.