Some small fixes in the API.
This commit is contained in:
parent
3b3d71bfd7
commit
7d163833bd
4 changed files with 8 additions and 2584 deletions
|
@ -45,9 +45,6 @@ class ApiException(Exception):
|
|||
return rv
|
||||
|
||||
|
||||
invalid_request = partial(ApiException, 'invalid_request', 400)
|
||||
|
||||
|
||||
class InvalidRequest(ApiException):
|
||||
def __init__(self, error_description, payload=None):
|
||||
ApiException.__init__(self, 'invalid_request', 400, error_description, payload)
|
||||
|
@ -206,7 +203,7 @@ def validate_json_request(schema_name):
|
|||
validate(request.get_json(), schema)
|
||||
return func(self, *args, **kwargs)
|
||||
except ValidationError as ex:
|
||||
InvalidRequest(ex.message)
|
||||
raise InvalidRequest(ex.message)
|
||||
return wrapped
|
||||
return wrapper
|
||||
|
||||
|
@ -222,8 +219,6 @@ def log_action(kind, user_or_orgname, metadata={}, repo=None):
|
|||
metadata=metadata, repository=repo)
|
||||
|
||||
|
||||
import endpoints.api.legacy
|
||||
|
||||
import endpoints.api.billing
|
||||
import endpoints.api.build
|
||||
import endpoints.api.discovery
|
||||
|
|
|
@ -206,12 +206,18 @@ class UserPlan(ApiResource):
|
|||
plan = request_data['plan']
|
||||
token = request_data['token'] if 'token' in request_data else None
|
||||
user = get_authenticated_user()
|
||||
if not user:
|
||||
raise Unauthorized()
|
||||
|
||||
return subscribe(user, plan, token, False) # Business features not required
|
||||
|
||||
@nickname('getUserSubscription')
|
||||
def get(self):
|
||||
""" Fetch any existing subscription for the user. """
|
||||
user = get_authenticated_user()
|
||||
if not user:
|
||||
raise Unauthorized()
|
||||
|
||||
private_repos = model.get_private_repo_count(user.username)
|
||||
|
||||
if user.stripe_id:
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -105,7 +105,7 @@ class RepositoryUserPermission(RepositoryParamResource):
|
|||
}
|
||||
|
||||
@require_repo_admin
|
||||
@nickname('getUserPermission')
|
||||
@nickname('getUserPermissions')
|
||||
def get(self, namespace, repository, username):
|
||||
""" Get the Fetch the permission for the specified user. """
|
||||
logger.debug('Get repo: %s/%s permissions for user %s' %
|
||||
|
|
Reference in a new issue