'GET /api/team/v0/team_membership'

def get(self, request):

    specified_username_or_team = False
    username = None
    team_id = None
    requested_course_id = None
    requested_course_key = None
    accessible_course_ids = None
    if ('course_id' in request.query_params):
        requested_course_id = request.query_params['course_id']
        try:
            requested_course_key = CourseKey.from_string(requested_course_id)
        except InvalidKeyError:
            return Response(status=status.HTTP_404_NOT_FOUND)
    if ('team_id' in request.query_params):
        specified_username_or_team = True
        team_id = request.query_params['team_id']
        try:
            team = CourseTeam.objects.get(team_id=team_id)
        except CourseTeam.DoesNotExist:
            return Response(status=status.HTTP_404_NOT_FOUND)
        if ((requested_course_key is not None) and (requested_course_key != team.course_id)):
            return Response(status=status.HTTP_400_BAD_REQUEST)
        if (not has_team_api_access(request.user, team.course_id)):
            return Response(status=status.HTTP_404_NOT_FOUND)
    if ('username' in request.query_params):
        specified_username_or_team = True
        username = request.query_params['username']
        if (not request.user.is_staff):
            enrolled_courses = CourseEnrollment.enrollments_for_user(request.user).values_list('course_id', flat=True)
            staff_courses = CourseAccessRole.objects.filter(user=request.user, role='staff').values_list('course_id', flat=True)
            accessible_course_ids = [item for sublist in (enrolled_courses, staff_courses) for item in sublist]
            if ((requested_course_id is not None) and (requested_course_id not in accessible_course_ids)):
                return Response(status=status.HTTP_400_BAD_REQUEST)
    if (not specified_username_or_team):
        return Response(build_api_error(ugettext_noop('username    or    team_id    must    be    specified.')), status=status.HTTP_400_BAD_REQUEST)
    course_keys = None
    if (requested_course_key is not None):
        course_keys = [requested_course_key]
    elif (accessible_course_ids is not None):
        course_keys = [CourseKey.from_string(course_string) for course_string in accessible_course_ids]
    queryset = CourseTeamMembership.get_memberships(username, course_keys, team_id)
    page = self.paginate_queryset(queryset)
    serializer = self.get_serializer(page, many=True)
    return self.get_paginated_response(serializer.data)
