Exemple #1
0
def GET(request):
    """Get this User."""

    request.check_required_parameters(path={'userId': 'string'})

    user = User.from_id(request.params_path['userId'])

    user.check_exists()

    return Response(200, 'Successfully retrieved user.', user.obj)
Exemple #2
0
def DELETE(request):
    """Delete this User."""

    request.check_required_parameters(path={'userId': 'string'})

    user = User.from_id(request.params_path['userId'])

    user.check_exists()
    user.check_correct_user(request.google_id)

    for authorization in user.obj['authorizations']:
        if authorization['authorizationLevel'] != 'OWN':
            continue

        project = Project.from_id(authorization['projectId'])
        project.delete()

    old_object = user.delete()

    return Response(200, 'Successfully deleted user.', old_object)
Exemple #3
0
def PUT(request):
    """Update this User's given name and/or family name."""

    request.check_required_parameters(
        body={'user': {
            'givenName': 'string',
            'familyName': 'string'
        }},
        path={'userId': 'string'})

    user = User.from_id(request.params_path['userId'])

    user.check_exists()
    user.check_correct_user(request.google_id)

    user.set_property('givenName', request.params_body['user']['givenName'])
    user.set_property('familyName', request.params_body['user']['familyName'])

    user.update()

    return Response(200, 'Successfully updated user.', user.obj)