Пример #1
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)
Пример #2
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
Пример #3
0
def is_following(login):
    if not is_authorized():
        return not_authorized_response()
    return boolean_response(204)
Пример #4
0
def star_subscribe(login, repo):
    if not is_authorized():
        return not_authorized_response()
    return boolean_response(204)