Port the remaining APIs and fix some locations.

This commit is contained in:
jakedt 2014-03-14 16:09:16 -04:00
parent 1bbe2283dc
commit dfdc3faa57
4 changed files with 42 additions and 8 deletions

View file

@ -6,7 +6,8 @@ from flask.ext.restful import abort
from app import app
from endpoints.api import (RepositoryParamResource, parse_args, query_param, nickname, resource,
require_repo_read, require_repo_write, validate_json_request)
require_repo_read, require_repo_write, validate_json_request,
ApiResource)
from endpoints.common import start_build
from data import model
from auth.permissions import ModifyRepositoryPermission
@ -126,7 +127,7 @@ class RepositoryBuildStatus(RepositoryParamResource):
return build_status_view(build, can_write)
@resource('/repository/<path:repository>/build/<build_uuid>/logs')
@resource('/v1/repository/<path:repository>/build/<build_uuid>/logs')
class RepositoryBuildLogs(RepositoryParamResource):
""" Resource for loading repository build logs. """
@require_repo_write
@ -148,3 +149,34 @@ class RepositoryBuildLogs(RepositoryParamResource):
})
return response_obj
@resource('/v1/filedrop/')
class FileDropResource(ApiResource):
""" Custom verb for setting up a client side file transfer. """
schemas = {
'FileDropRequest': {
'id': 'FileDropRequest',
'type': 'object',
'description': 'Description of the file that the user wishes to upload.',
'required': True,
'properties': {
'mimeType': {
'type': 'string',
'description': 'Type of the file which is about to be uploaded',
'required': True,
},
},
},
}
@nickname('getFiledropUrl')
@validate_json_request('FileDropRequest')
def post(self):
""" Request a URL to which a file may be uploaded. """
mime_type = request.get_json()['mimeType']
(url, file_id) = user_files.prepare_for_drop(mime_type)
return {
'url': url,
'file_id': file_id
}

View file

@ -117,6 +117,7 @@ def welcome():
return jsonify({'version': '0.5'})
# Ported
@api_bp.route('/plans/')
def list_plans():
return jsonify({
@ -1623,6 +1624,7 @@ def delete_build_trigger(namespace, repository, trigger_uuid):
abort(403) # Permission denied
# Ported
@api_bp.route('/filedrop/', methods=['POST'])
@api_login_required
@internal_api_call

View file

@ -14,7 +14,7 @@ def robot_view(name, token):
}
@resource('/user/robots')
@resource('/v1/user/robots')
class UserRobotList(ApiResource):
""" Resource for listing user robots. """
@nickname('getUserRobots')
@ -27,7 +27,7 @@ class UserRobotList(ApiResource):
}
@resource('/user/robots/<robot_shortname>')
@resource('/v1/user/robots/<robot_shortname>')
class UserRobot(ApiResource):
""" Resource for managing a user's robots. """
@nickname('createUserRobot')
@ -49,7 +49,7 @@ class UserRobot(ApiResource):
return 'Deleted', 204
@resource('/organization/<orgname>/robots')
@resource('/v1/organization/<orgname>/robots')
class OrgRobotList(ApiResource):
""" Resource for listing an organization's robots. """
@nickname('getOrgRobots')
@ -66,7 +66,7 @@ class OrgRobotList(ApiResource):
abort(403)
@resource('/organization/<orgname>/robots/<robot_shortname>')
@resource('/v1/organization/<orgname>/robots/<robot_shortname>')
class OrgRobot(ApiResource):
""" Resource for managing an organization's robots. """
@nickname('createOrgRobot')

View file

@ -209,7 +209,7 @@ class BuildTriggerActivate(RepositoryParamResource):
abort(403)
@resource('/repository/<path:repository>/trigger/<trigger_uuid>/start')
@resource('/v1/repository/<path:repository>/trigger/<trigger_uuid>/start')
class ActivateBuildTrigger(RepositoryParamResource):
""" Custom verb to manually activate a build trigger. """
@ -260,7 +260,7 @@ class TriggerBuildList(RepositoryParamResource):
}
@resource('/repository/<path:repository>/trigger/<trigger_uuid>/sources')
@resource('/v1/repository/<path:repository>/trigger/<trigger_uuid>/sources')
class BuildTriggerSources(RepositoryParamResource):
""" Custom verb to fetch the list of build sources for the trigger config. """
@require_repo_admin