lms.djangoapps.support.rest_api.v1 package#

Submodules#

lms.djangoapps.support.rest_api.v1.urls module#

URL definitions for the course_modes v1 API.

lms.djangoapps.support.rest_api.v1.views module#

API Views for course team management in support app.

class lms.djangoapps.support.rest_api.v1.views.CourseTeamManageAPIView(*args, **kwargs)#

Bases: GenericAPIView

Use case:
  • APIs for viewing and managing a user’s course team roles.

  • Lists courses where the authenticated user has permission to manage roles.

  • Displays the given user’s role in each accessible course.

  • Allows assigning or revoking roles via PUT, limited to courses the user can manage.

get(request, *args, **kwargs)#

Retrieve a list of courses accessible by the authenticated user

Use Case

GET API to retrieve a list of courses accessible by the authenticated user, along with the specified user’s role (“instructor”, “staff”, or null) in each course.

Endpoint

GET /api/support/v1/manage_course_team/

Query Parameters

At least one of the following parameters is required: - email: User’s email address - username: User’s username - user_id: User’s ID

Returns

List of courses accessible to the authenticated user, each annotated with the specified user’s role in that course. Each course includes organizational information and identifiers.

Example Response

```json
{
“results”: [
{

“course_id”: “course-v1:edX+DemoX+2025_T1”, “course_name”: “edX Demonstration Course”, “course_url”: “https://studio.example.com/course/course-v1:edX+DemoX+2025_T1”, “role”: “instructor”, “status”: “active”, “org”: “edX”, “run”: “2025_T1”, “number”: “DemoX”

}, {

“course_id”: “course-v1:MITx+6.00x+2024_Fall”, “course_name”: “Introduction to Computer Science”, “course_url”: “https://studio.example.com/course/course-v1:MITx+6.00x+2024_Fall”, “role”: “staff”, “status”: “archived”, “org”: “MITx”, “run”: “2024_Fall”, “number”: “6.00x”

}

]

}

```

get_accessible_courses_for_user(auth_user)#

Return queryset of courses accessible by the authenticated user.

get_course_role_map_for_user(user)#

Return a mapping of course_id to role for staff/instructor roles of given user.

get_queryset()#

Main entry to return courses filtered by authenticated user access and requested user roles.

get_serializer_context()#

Provide extra context to the serializer.

list(request, *args, **kwargs)#

list of courses for the organization and user.

openapi = <module 'drf_yasg.openapi' from '/home/docs/checkouts/readthedocs.org/user_builds/edx-platform-docs/envs/latest/lib/python3.12/site-packages/drf_yasg/openapi.py'>#
pagination_class = None#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
put(request, *args, **kwargs)#

Bulk assign or revoke course team roles for a user across multiple courses.

Endpoint

PUT /api/support/v1/manage_course_team/

Permissions

  • Admin/Staff users: Can manage roles for any course

  • Instructor users: Can only manage roles for courses/orgs they have instructor access to

  • Other users: Access denied

Request Data

A JSON object containing:
  • email: User’s email address

  • bulk_role_operations: List of role operations, each containing:
    • course_id: Course key string

    • role: Role to assign or revoke (“instructor” or “staff”)

    • action: “assign” or “revoke”

Example Request

```json {

“email”: “user1@example.com”, “bulk_role_operations”: [

{

“course_id”: “course-v1:edX+DemoX+2025_T1”, “role”: “instructor”, “action”: “assign”

}, {

“course_id”: “course-v1:edX+DemoX+2025_T2”, “role”: “staff”, “action”: “revoke”

}

]

}#

Returns

  • HTTP 200 with results for each operation (success or error details)

  • HTTP 400 if the request data is invalid

Example Response

```json {

“email”: “user1@example.com”, “results”: [

{

“course_id”: “course-v1:edX+DemoX+2025_T1”, “role”: “instructor”, “action”: “assign”, “status”: “success”

}, {

“course_id”: “course-v1:edX+DemoX+2025_T2”, “role”: “staff”, “action”: “revoke”, “status”: “failed”, “error”: “error_message”

}

]

}#

serializer_class#

alias of CourseTeamManageSerializer

swagger_auto_schema(methods=None, auto_schema=<class 'drf_yasg.utils.unset'>, request_body=None, query_serializer=None, manual_parameters=None, operation_id=None, operation_description=None, operation_summary=None, security=None, deprecated=None, responses=None, field_inspectors=None, filter_inspectors=None, paginator_inspectors=None, tags=None, produces=None, consumes=None, **extra_overrides)#

Decorate a view method to customize the Operation object generated from it.

method and methods are mutually exclusive and must only be present when decorating a view method that accepts more than one HTTP request method.

The auto_schema and operation_description arguments take precedence over view- or method-level values.

Parameters:
  • method (str) – for multi-method views, the http method the options should apply to

  • methods (list[str]) – for multi-method views, the http methods the options should apply to

  • auto_schema (drf_yasg.inspectors.SwaggerAutoSchema) – custom class to use for generating the Operation object; this overrides both the class-level swagger_schema attribute and the DEFAULT_AUTO_SCHEMA_CLASS setting, and can be set to None to prevent this operation from being generated

  • request_body (drf_yasg.openapi.Schema or drf_yasg.openapi.SchemaRef or rest_framework.serializers.Serializer or type[no_body]) –

    custom request body which will be used as the schema property of a Parameter with in: 'body'.

    A Schema or SchemaRef is not valid if this request consumes form-data, because form and body parameters are mutually exclusive in an Operation. If you need to set custom form parameters, you can use the manual_parameters argument.

    If a Serializer class or instance is given, it will be automatically converted into a Schema used as a body Parameter, or into a list of form Parameters, as appropriate.

  • query_serializer (rest_framework.serializers.Serializer) –

    if you use a Serializer to parse query parameters, you can pass it here and have Parameter objects be generated automatically from it.

    If any Field on the serializer cannot be represented as a query Parameter (e.g. nested Serializers, file fields, …), the schema generation will fail with an error.

    Schema generation will also fail if the name of any Field on the query_serializer conflicts with parameters generated by filter_backends or paginator.

  • manual_parameters (list[drf_yasg.openapi.Parameter]) –

    a list of manual parameters to override the automatically generated ones

    Parameters are identified by their (name, in) combination,

    and any parameters given here will fully override automatically generated parameters if they collide.

    It is an error to supply form parameters when the request does not consume form-data.

  • operation_id (str) – operation ID override; the operation ID must be unique across the whole API

  • operation_description (str) – operation description override

  • operation_summary (str) – operation summary string

  • security (list[dict]) – security requirements override; used to specify which authentication mechanism is required to call this API; an empty list marks the endpoint as unauthenticated (i.e. removes all accepted authentication schemes), and None will inherit the top-level security requirements

  • deprecated (bool) – deprecation status for operation

  • responses (dict[int or str, (drf_yasg.openapi.Schema or drf_yasg.openapi.SchemaRef or drf_yasg.openapi.Response or str or rest_framework.serializers.Serializer)]) –

    a dict of documented manual responses keyed on response status code. If no success (2xx) response is given, one will automatically be generated from the request body and http method. If any 2xx response is given the automatic response is suppressed.

    • if a plain string is given as value, a Response with no body and that string as its description will be generated

    • if None is given as a value, the response is ignored; this is mainly useful for disabling default 2xx responses, i.e. responses={200: None, 302: 'something'}

    • if a Schema, SchemaRef is given, a Response with the schema as its body and an empty description will be generated

    • a Serializer class or instance will be converted into a Schema and treated as above

    • a Response object will be used as-is; however if its schema attribute is a Serializer, it will automatically be converted into a Schema

  • field_inspectors (list[type[drf_yasg.inspectors.FieldInspector]]) – extra serializer and field inspectors; these will be tried before ViewInspector.field_inspectors on the inspectors.SwaggerAutoSchema

  • filter_inspectors (list[type[drf_yasg.inspectors.FilterInspector]]) – extra filter inspectors; these will be tried before ViewInspector.filter_inspectors on the inspectors.SwaggerAutoSchema

  • paginator_inspectors (list[type[drf_yasg.inspectors.PaginatorInspector]]) – extra paginator inspectors; these will be tried before ViewInspector.paginator_inspectors on the inspectors.SwaggerAutoSchema

  • tags (list[str]) – tags override

  • produces (list[str]) – produces override

  • consumes (list[str]) – consumes override

  • extra_overrides – extra values that will be saved into the overrides dict; these values will be available in the handling inspectors.SwaggerAutoSchema instance via self.overrides

Module contents#