Exemplo n.º 1
0
def repos():
    if not is_authorized():
        return not_authorized_response()

    if request.method == 'POST':
        if not (request.json and request.json.get('name')):
            return failed_validation_response()

    return response_from_fixture('repo', True, paginate=True)
Exemplo n.º 2
0
def key(id):
    if not is_authorized():
        return not_authorized_response()

    if request.method == 'DELETE':
        return boolean_response(204)
    elif request.method == 'PATCH':
        valid = valid_key = False
        if request.json:
            valid = request.json.get('title') and request.json.get('key')
            key = request.json.get('key', '')
            valid_key = key.startswith('ssh-rsa ') and len(key) >= 8

        if not (valid_key and valid):
            return failed_validation_response()

    return response_from_fixture('key', status_code=404)
Exemplo n.º 3
0
def emails():
    if not is_authorized():
        return not_authorized_response()

    valid = False
    data = request.json
    if data:
        is_str = all([isinstance(e, basestring) for e in data])
        if isinstance(data, list) and is_str:
            valid = True

    response = response_from_fixture('emails', True)
    if valid:
        if request.method == 'POST':
            response.status_code = 201
        elif request.method == 'DELETE':
            response = boolean_response(204)
    elif request.method != 'GET':
        response = failed_validation_response()

    return response
Exemplo n.º 4
0
def orgs():
    if not is_authorized():
        return not_authorized_response()
    return response_from_fixture('org', True)
Exemplo n.º 5
0
def keys():
    if not is_authorized():
        return not_authorized_response()
    return response_from_fixture('key', True)
Exemplo n.º 6
0
def user():
    if not is_authorized():
        return not_authorized_response()
    return response_from_fixture('user', status_code=404)
Exemplo n.º 7
0
def issues():
    if not is_authorized():
        return not_authorized_response()
    return response_from_fixture('issue', True)
Exemplo n.º 8
0
def is_following(login):
    if not is_authorized():
        return not_authorized_response()
    return boolean_response(204)
Exemplo n.º 9
0
def iter_following():
    if not is_authorized():
        return not_authorized_response()
    return response_from_fixture('user', True)
Exemplo n.º 10
0
def star_subscribe(login, repo):
    if not is_authorized():
        return not_authorized_response()
    return boolean_response(204)
Exemplo n.º 11
0
def starred_subscribed():
    if not is_authorized():
        return not_authorized_response()
    return response_from_fixture('repo', True, paginate=True)