'GET /api/team/v0/teams/'

def get(self, request):

    result_filter = {}
    if ('course_id' in request.query_params):
        course_id_string = request.query_params['course_id']
        try:
            course_key = CourseKey.from_string(course_id_string)
            course_module = modulestore().get_course(course_key)
            if (course_module is None):
                return Response(status=status.HTTP_404_NOT_FOUND)
            result_filter.update({'course_id': course_key})
        except InvalidKeyError:
            error = build_api_error(ugettext_noop('The    supplied    course    id    {course_id}    is    not    valid.'), course_id=course_id_string)
            return Response(error, status=status.HTTP_400_BAD_REQUEST)
        if (not has_team_api_access(request.user, course_key)):
            return Response(status=status.HTTP_403_FORBIDDEN)
    else:
        return Response(build_api_error(ugettext_noop('course_id    must    be    provided')), status=status.HTTP_400_BAD_REQUEST)
    text_search = request.query_params.get('text_search', None)
    if (text_search and request.query_params.get('order_by', None)):
        return Response(build_api_error(ugettext_noop('text_search    and    order_by    cannot    be    provided    together')), status=status.HTTP_400_BAD_REQUEST)
    username = request.query_params.get('username', None)
    if (username is not None):
        result_filter.update({'membership__user__username': username})
    topic_id = request.query_params.get('topic_id', None)
    if (topic_id is not None):
        if (topic_id not in [topic['id'] for topic in course_module.teams_configuration['topics']]):
            error = build_api_error(ugettext_noop('The    supplied    topic    id    {topic_id}    is    not    valid'), topic_id=topic_id)
            return Response(error, status=status.HTTP_400_BAD_REQUEST)
        result_filter.update({'topic_id': topic_id})
    if (text_search and CourseTeamIndexer.search_is_enabled()):
        try:
            search_engine = CourseTeamIndexer.engine()
        except ElasticSearchConnectionError:
            return Response(build_api_error(ugettext_noop('Error    connecting    to    elasticsearch')), status=status.HTTP_503_SERVICE_UNAVAILABLE)
        result_filter.update({'course_id': course_id_string})
        search_results = search_engine.search(query_string=text_search, field_dictionary=result_filter, size=MAXIMUM_SEARCH_SIZE)
        paginated_results = paginate_search_results(CourseTeam, search_results, self.paginator.get_page_size(request), self.get_page())
        emit_team_event('edx.team.searched', course_key, {'number_of_results': search_results['total'], 'search_text': text_search, 'topic_id': topic_id})
        page = self.paginate_queryset(paginated_results)
        serializer = self.get_serializer(page, many=True)
        order_by_input = None
    else:
        queryset = CourseTeam.objects.filter(**result_filter)
        order_by_input = request.query_params.get('order_by', 'name')
        if (order_by_input == 'name'):
            queryset = queryset.order_by('name')
        elif (order_by_input == 'open_slots'):
            queryset = queryset.order_by('team_size', '-last_activity_at')
        elif (order_by_input == 'last_activity_at'):
            queryset = queryset.order_by('-last_activity_at', 'team_size')
        else:
            return Response({'developer_message': 'unsupported    order_by    value    {ordering}'.format(ordering=order_by_input), 'user_message': _(u'The    ordering    {ordering}    is    not    supported').format(ordering=order_by_input)}, status=status.HTTP_400_BAD_REQUEST)
        page = self.paginate_queryset(queryset)
        serializer = self.get_serializer(page, many=True)
    response = self.get_paginated_response(serializer.data)
    if (order_by_input is not None):
        response.data['sort_order'] = order_by_input
    return response
