enterprise.api.v1.views package

Contents

enterprise.api.v1.views package#

Submodules#

enterprise.api.v1.views.analytics_summary module#

Views for the ChatGPTResponse API endpoint.

class enterprise.api.v1.views.analytics_summary.AnalyticsSummaryView(**kwargs)#

Bases: GenericAPIView

API to retrieve analytics summary using Xpert AI

authentication_classes = [<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>]#
http_method_names = ['post']#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
post(request, enterprise_uuid)#

Perform analysis on given data and return result from Xpert AI.

enterprise.api.v1.views.base_views module#

Base API views for the enterprise app.

class enterprise.api.v1.views.base_views.EnterpriseModelViewSet#

Bases: EnterpriseViewSet

Base class for attribute and method definitions common to all view sets.

USER_ID_FILTER = 'id'#
filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'enterprise.api.filters.UserFilterBackend'>)#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'rest_framework.permissions.DjangoModelPermissions'>)#
class enterprise.api.v1.views.base_views.EnterpriseReadOnlyModelViewSet(**kwargs)#

Bases: EnterpriseModelViewSet, ReadOnlyModelViewSet

Base class for all read only Enterprise model view sets.

class enterprise.api.v1.views.base_views.EnterpriseReadWriteModelViewSet(**kwargs)#

Bases: EnterpriseModelViewSet, ModelViewSet

Base class for all read/write Enterprise model view sets.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'rest_framework.permissions.DjangoModelPermissions'>)#
class enterprise.api.v1.views.base_views.EnterpriseViewSet#

Bases: object

Base class for all Enterprise view sets.

authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
ensure_data_exists(request, data, error_message=None)#

Ensure that the wrapped API client’s response brings us valid data. If not, raise an error and log it.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
throttle_classes = (<class 'enterprise.api.throttles.ServiceUserThrottle'>,)#
class enterprise.api.v1.views.base_views.EnterpriseWrapperApiViewSet(**kwargs)#

Bases: EnterpriseViewSet, ViewSet

Base class for attribute and method definitions common to all view sets which wrap external APIs.

class enterprise.api.v1.views.base_views.EnterpriseWriteOnlyModelViewSet(**kwargs)#

Bases: EnterpriseModelViewSet, CreateModelMixin, UpdateModelMixin, GenericViewSet

Base class for all write only Enterprise model view sets.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'rest_framework.permissions.DjangoModelPermissions'>)#

enterprise.api.v1.views.coupon_codes module#

Views for coupon codes.

class enterprise.api.v1.views.coupon_codes.CouponCodesView(**kwargs)#

Bases: APIView

API to request coupon codes.

MISSING_REQUIRED_PARAMS_MSG = 'Some required parameter(s) missing: {}'#
OPTIONAL_PARAM_NOTES = 'notes'#
OPTIONAL_PARAM_NUMBER_OF_CODES = 'number_of_codes'#
REQUIRED_PARAM_EMAIL = 'email'#
REQUIRED_PARAM_ENTERPRISE_NAME = 'enterprise_name'#
authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
get_missing_params_message(parameter_state)#

Get a user-friendly message indicating a missing parameter for the API endpoint.

get_required_query_params(request)#

Gets email, enterprise_name, number_of_codes, and notes, which are the relevant parameters for this API endpoint.

Parameters:

request – The request to this endpoint.

Returns:

The email, enterprise_name, number_of_codes and notes from the request.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
post(request)#

POST /enterprise/api/v1/request_codes

Requires a JSON object of the following format:

{
    "email": "bob@alice.com",
    "enterprise_name": "IBM",
    "number_of_codes": "50",
    "notes": "Help notes for codes request",
}
Keys:
  • email – Email of the customer who has requested more codes.

  • enterprise_name – The name of the enterprise requesting more codes.

  • number_of_codes – The number of codes requested.

  • notes – Help notes related to codes request.

throttle_classes = (<class 'enterprise.api.throttles.ServiceUserThrottle'>,)#

enterprise.api.v1.views.default_enterprise_enrollments module#

Views for default enterprise enrollments.

class enterprise.api.v1.views.default_enterprise_enrollments.DefaultEnterpriseEnrollmentIntentionViewSet(**kwargs)#

Bases: PermissionRequiredForListingMixin, EnterpriseViewSet, ReadOnlyModelViewSet

API views for default enterprise enrollment intentions

allowed_roles = ['default_enterprise_enrollment_intentions_learner']#
property base_queryset#

Required by the PermissionRequiredForListingMixin. For non-list actions, this is what’s returned by get_queryset(). For list actions, some non-strict subset of this is what’s returned by get_queryset().

basename = None#
description = None#
detail = None#
get_permission_object()#

Used for “retrieve” actions. Determines the context (enterprise UUID) to check against for role-based permissions.

learner_status(request)#

Get the status of the learner’s enrollment in the default enterprise course.

list_lookup_field = 'enterprise_customer__uuid'#
name = None#
permission_required = 'enterprise.can_view_default_enterprise_enrollment_intentions'#
property requested_enterprise_customer_uuid#

Get and validate the enterprise customer UUID from the query parameters.

property requested_lms_user_id#

Get the (optional) LMS user ID from the request.

serializer_class#

alias of DefaultEnterpriseEnrollmentIntentionSerializer

suffix = None#
user_for_learner_status#

Get the user for learner status based on the request.

enterprise.api.v1.views.enterprise_admin_members module#

Views for the enterprise-admin-members API endpoint.

class enterprise.api.v1.views.enterprise_admin_members.EnterpriseAdminMembersPagination#

Bases: PageNumberPagination

Pagination class for the enterprise admin members endpoint.

max_page_size = 100#
page_size = 10#
page_size_query_param = 'page_size'#
class enterprise.api.v1.views.enterprise_admin_members.EnterpriseAdminMembersViewSet(**kwargs)#

Bases: EnterpriseViewSet, ListModelMixin, GenericViewSet

API for listing enterprise admin members (both active and pending).

GET /{enterprise_uuid}/admins

Returns a paginated list of enterprise administrators with status:
  • Admin – Active admin (joined)

  • Pending – Admin invited but not yet joined

Query parameters:
  • user_query – Filter by name or email (case-insensitive contains)

  • ordering – One of: name, email, joined_date, invited_date, status

    Prefix with - for descending (e.g. -name)

basename = None#
description = None#
detail = None#
filter_backends = (<class 'rest_framework.filters.OrderingFilter'>,)#
get_queryset()#

Build a union queryset of active + pending admins, scoped to the requested enterprise. Applies user_query search filtering before the union (since union querysets do not support .filter()).

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

List enterprise admin members with DRF-native ordering and pagination.

name = None#
ordering = ['name', 'email']#
ordering_fields = ['name', 'email', 'joined_date', 'invited_date', 'status']#
pagination_class#

alias of EnterpriseAdminMembersPagination

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
serializer_class#

alias of EnterpriseAdminMemberSerializer

suffix = None#

enterprise.api.v1.views.enterprise_catalog_query module#

Views for the enterprise-catalog-query API endpoint.

class enterprise.api.v1.views.enterprise_catalog_query.EnterpriseCatalogQueryViewSet(**kwargs)#

Bases: EnterpriseReadOnlyModelViewSet

API views for the enterprise_catalog_query API endpoint.

authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
basename = None#
description = None#
detail = None#
name = None#
pagination_class#

alias of ExpandDefaultPageSize

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'rest_framework.permissions.IsAdminUser'>)#
queryset#
serializer_class#

alias of EnterpriseCatalogQuerySerializer

suffix = None#
class enterprise.api.v1.views.enterprise_catalog_query.ExpandDefaultPageSize#

Bases: PageNumberPagination

Expands page size for the API. Used to populate support-tools repo’s provisioning form catalog query dropdown component.

page_size = 100#

enterprise.api.v1.views.enterprise_course_enrollment module#

Views for the enterprise-course-enrollment API endpoint.

class enterprise.api.v1.views.enterprise_course_enrollment.EnterpriseCourseEnrollmentAdminPagination#

Bases: PageNumberPagination

Custom pagination class for Enterprise Course Enrollment API.

max_page_size = 100#
page_size = 10#
page_size_query_param = 'page_size'#
class enterprise.api.v1.views.enterprise_course_enrollment.EnterpriseCourseEnrollmentAdminViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the enterprise-course-enrollment-admin API endpoint.

basename = None#
description = None#
detail = None#
get_enterprise_course_enrollments(request)#

Endpoint to get enrollments for a learner by lms_user_id and enterprise_uuid viewed by an admin of that enterprise.

Returns an empty result set if the enterprise customer has enable_data_sharing_consent set to False. Audit enrollments are included only when the enterprise customer has enable_audit_data_reporting set to True; otherwise only non-audit enrollments are returned.

Parameters: - lms_user_id (str): Filter results by the LMS user ID. - enterprise_uuid (str): Filter results by the Enterprise UUID.

name = None#
pagination_class#

alias of EnterpriseCourseEnrollmentAdminPagination

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'rest_framework.permissions.IsAdminUser'>)#
queryset#
serializer_class#

alias of EnterpriseCourseEnrollmentAdminViewSerializer

suffix = None#
class enterprise.api.v1.views.enterprise_course_enrollment.EnterpriseCourseEnrollmentPagination#

Bases: DefaultPagination

django_paginator_class#

alias of PaginatorWithOptimizedCount

class enterprise.api.v1.views.enterprise_course_enrollment.EnterpriseCourseEnrollmentViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the enterprise-course-enrollment API endpoint.

FIELDS = ('enterprise_customer_user', 'course_id')#
USER_ID_FILTER = 'enterprise_customer_user__user_id'#
basename = None#
description = None#
detail = None#
filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'enterprise.api.filters.EnterpriseCourseEnrollmentFilterBackend'>)#
filterset_fields = ('enterprise_customer_user', 'course_id')#
get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

get_serializer_class()#

Use a special serializer for any requests that aren’t read-only.

name = None#
ordering_fields = ('enterprise_customer_user', 'course_id')#
pagination_class#

alias of EnterpriseCourseEnrollmentPagination

queryset#
suffix = None#
class enterprise.api.v1.views.enterprise_course_enrollment.PaginatorWithOptimizedCount(object_list, per_page, orphans=0, allow_empty_first_page=True, error_messages=None)#

Bases: Paginator

Django < 4.2 ORM doesn’t strip unused annotations from count queries.

For example, if we execute this query:

Book.objects.annotate(Count(‘chapters’)).count()

it will generate SQL like this:

SELECT COUNT(*) FROM (SELECT COUNT(…), … FROM …) subquery

This isn’t optimal on its own, but it’s not a big deal. However, this becomes problematic when annotations use subqueries, because it’s terribly inefficient to execute the subquery for every row in the outer query.

This class overrides the count() method of Django’s Paginator to strip unused annotations from the query by requesting only the primary key instead of all fields.

This is a temporary workaround until Django is updated to 4.2, which will include a fix for this issue.

See https://code.djangoproject.com/ticket/32169 for more details.

TODO: remove this class once Django is updated to 4.2 or higher.

count#
enterprise.api.v1.views.enterprise_course_enrollment.read_replica_or_default()#

enterprise.api.v1.views.enterprise_customer module#

Views for the enterprise-customer API endpoint.

class enterprise.api.v1.views.enterprise_customer.EnterpriseCustomerViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the enterprise-customer API endpoint.

FIELDS = ('uuid', 'slug', 'name', 'active', 'site', 'enable_data_sharing_consent', 'enforce_data_sharing_consent')#
USER_ID_FILTER = 'enterprise_customer_users__user_id'#
basename = None#
basic_list(request, *arg, **kwargs)#

Enterprise Customer’s Basic data list without pagination

Two query parameters are supported: - name_or_uuid: filter by name or uuid substring search in a single query parameter. Primarily used for frontend debounced input search. - startswith: filter by name starting with the given string

contains_content_items(request, pk, course_run_ids, program_uuids)#

Return whether or not the specified content is available to the EnterpriseCustomer.

Multiple course_run_ids and/or program_uuids query parameters can be sent to this view to check for their existence in the EnterpriseCustomerCatalogs associated with this EnterpriseCustomer. At least one course run key or program UUID value must be included in the request.

course_enrollments(request, pk)#

Creates a course enrollment for an EnterpriseCustomerUser.

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

POST /enterprise/api/v1/enterprise-customer/

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

Supports listing dashboard enterprises for frontend-app-admin-portal.

description = None#
detail = None#
enroll_learners_in_courses(request, pk)#

Creates a set of enterprise enrollments for specified learners by bulk enrolling them in provided courses. This endpoint is not transactional, in that any one or more failures will not affect other successful enrollments made within the same request.

Parameters:
  • enrollments_info (list of dicts) –

    an array of dictionaries, each containing the necessary information to create an enrollment based on a subsidy for a user in a specified course. Each dictionary must contain the following keys:

    • ’user_id’ OR ‘email’: Either unique identifier describing the user to enroll.

    • ’course_run_key’: The course to enroll into.

    • ’license_uuid’ OR ‘transaction_id’: ID of either accepted form of subsidy. license_uuid refers to subscription licenses, and transaction_id refers to Learner Credit transactions.

    • ’force_enrollment’ (bool, optional): Enroll even if enrollment deadline is expired (default False).

    licenses_info is also accepted as a body param name.

    Example:

    enrollments_info: [
        {
            'email': 'newuser@test.com',
            'course_run_key': 'course-v1:edX+DemoX+Demo_Course',
            'license_uuid': '5b77bdbade7b4fcb838f8111b68e18ae',
        },
        {
            'email': 'newuser2@test.com',
            'course_run_key': 'course-v2:edX+FunX+Fun_Course',
            'transaction_id': '84kdbdbade7b4fcb838f8asjke8e18ae',
        },
        {
            'user_id': 1234,
            'course_run_key': 'course-v2:edX+SadX+Sad_Course',
            'transaction_id': 'ba1f7b61951987dc2e1743fa4886b62d',
        },
        ...
    ]
    

  • discount (int) – the percent discount to be applied to all enrollments. Defaults to 100.

Returns:

  • All users exist and are enrolled -

    {‘successes’: [], ‘pending’: [], ‘failures’: []}, 201

  • Some or none of the users exist but are enrolled -

    {‘successes’: [], ‘pending’: [], ‘failures’: []}, 202

Failure cases:
  • Some or all of the users can’t be enrolled, no users were enrolled -

    {‘successes’: [], ‘pending’: [], ‘failures’: []}, 409

  • Some or all of the provided emails are invalid

    {‘successes’: [], ‘pending’: [], ‘failures’: [] ‘invalid_email_addresses’: []}, 409

Return type:

Success cases

filterset_fields = ('uuid', 'slug', 'name', 'active', 'site', 'enable_data_sharing_consent', 'enforce_data_sharing_consent')#
get_permissions()#

Instantiates and returns the list of permissions that this view requires.

get_queryset()#

Allow PAs to access all enterprise customers by modifying filter_backends

get_serializer_class()#

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

name = None#
ordering_fields = ('uuid', 'slug', 'name', 'active', 'site', 'enable_data_sharing_consent', 'enforce_data_sharing_consent')#
pagination_class#

alias of PaginationWithFeatureFlags

partial_update(request, *args, **kwargs)#
queryset#
serializer_class#

alias of EnterpriseCustomerSerializer

suffix = None#
support_tool(request, *arg, **kwargs)#

Enterprise Customer’s detail data with pagination for the support tool

Supported query param: - uuid: filter the enterprise customer uuid . - user_query: filter the enterprise customer name.

throttle_classes = (<class 'enterprise.api.throttles.HighServiceUserThrottle'>,)#

Enables/Disables universal link config.

Unlink request user from the enterprise.

Unlinks users with the given emails from the enterprise.

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

Returns the list of enterprise customers the user has a specified group permission access to.

enterprise.api.v1.views.enterprise_customer_admin module#

Views for EnterpriseCustomerAdmin model.

class enterprise.api.v1.views.enterprise_customer_admin.EnterpriseCustomerAdminPagination#

Bases: PageNumberPagination

Pagination class for EnterpriseCustomerAdmin viewset.

max_page_size = 100#
page_size = 10#
page_size_query_param = 'page_size'#
class enterprise.api.v1.views.enterprise_customer_admin.EnterpriseCustomerAdminViewSet(**kwargs)#

Bases: ListModelMixin, UpdateModelMixin, RetrieveModelMixin, GenericViewSet

API views for the enterprise-customer-admin API endpoint. Only allows GET, and PATCH requests.

basename = None#
complete_tour_flow(request, pk=None)#

Add a completed tour flow to the admin’s completed_tour_flows. POST /api/v1/enterprise-customer-admin/{pk}/complete_tour_flow/

Request Arguments: - flow_uuid: The request object containing the flow_uuid

Returns: A response indicating success or failure

create_admin_by_email(request)#

Create a new EnterpriseCustomerAdmin record based on an email address. The email address must match an existing user.

POST /api/v1/enterprise-customer-admin/create_admin_by_email/

The requesting user must have the enterprise_provisioning_admin role to access this endpoint.

Request Arguments: - email: Email address of the user to make an admin - enterprise_customer_uuid: UUID of the enterprise customer

Returns: A response with the created admin record.

delete_admin(request, enterprise_customer_uuid=None, id=None)#

Delete an admin record based on role.

DELETE /enterprise/api/v1/enterprise-customer/{enterprise_customer_uuid}/admins/{id}/?role=<role>

Path Parameters:

  • enterprise_customer_uuid: UUID of the enterprise customer.

  • id: ID of the admin record to delete (PendingEnterpriseCustomerAdminUser ID or EnterpriseCustomerUser ID)

Query Parameters:

  • role: Either ‘pending’ or ‘admin’ (required, case-insensitive)

Role handling: role='pending' hard deletes PendingEnterpriseCustomerAdminUser where id=id. role='admin' deletes role assignment from SystemWideEnterpriseUserRoleAssignment for EnterpriseCustomerUser id=id, and deactivates EnterpriseCustomerUser if no other roles exist.

Returns:

200 OK with success message and user_deactivated flag (for active admins) 400 BAD REQUEST if role parameter is missing or invalid 404 NOT FOUND if the specified admin record doesn’t exist

description = None#
detail = None#
get_queryset()#

Filter queryset to only show records for the admin user. Excludes admins whose EnterpriseCustomerUser has been deactivated.

invite_admins(request, **kwargs)#

Invite new admins to an Enterprise Customer by sending invitation emails.

POST /enterprise/api/v1/enterprise-customer-admin/{enterprise_customer_uuid}/admin-invites

Request data must include:

  • emails: list of email addresses to invite

  • enterprise_customer_uuid: UUID of the enterprise customer

Returns:

A list of dicts with email and status for each attempted invite.

name = None#
pagination_class#

alias of EnterpriseCustomerAdminPagination

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
queryset#
serializer_class#

alias of EnterpriseCustomerAdminSerializer

suffix = None#

enterprise.api.v1.views.enterprise_customer_api_credentials module#

Views for the Enterprise Customer API Credentials.

class enterprise.api.v1.views.enterprise_customer_api_credentials.APICredEnabledPermission#

Bases: BasePermission

Permission that checks to see if the request user matches the user indicated in the request body.

has_permission(request, view)#

Return True if permission is granted, False otherwise.

class enterprise.api.v1.views.enterprise_customer_api_credentials.APICredentialsRegenerateViewSet(**kwargs)#

Bases: APICredentialsViewSet

API views for the enterprise-customer-api-credentials API endpoint.

basename = None#
description = None#
detail = None#
get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

get_serializer_class()#

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

name = None#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'enterprise.api.v1.views.enterprise_customer_api_credentials.APICredEnabledPermission'>)#
suffix = None#
update(request, *args, **kwargs)#

Regenerates the API application credentials (client ID and secret) for the requesting user. Throws a 404 if the user does not yet have any credentials.

Method: PUT

URL: /enterprise/api/v1/enterprise-customer-api-credentials/{enterprise_uuid}/regenerate_credentials

class enterprise.api.v1.views.enterprise_customer_api_credentials.APICredentialsViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the enterprise-customer-api-credentials API endpoint.

basename = None#
create(request, *args, **kwargs)#

Creates and returns a new enterprise API credential application record.

Method: POST

URL:

/enterprise/api/v1/enterprise-customer-api-credentials/{enterprise_uuid}

Returns:

201 if a new API application credentials was created. If an application already exists for the user, throw a 409.

description = None#
destroy(request, *args, **kwargs)#

Removes the enterprise API application credentials for the requesting user.

Method: DELETE

URL: /enterprise/api/v1/enterprise-customer-api-credentials/{enterprise_uuid}

detail = None#
get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

get_serializer_class()#

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

name = None#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'enterprise.api.v1.views.enterprise_customer_api_credentials.APICredEnabledPermission'>)#
retrieve(request, *args, **kwargs)#

Returns the enterprise API application credentials details for the requesting user.

Method: GET

URL: /enterprise/api/v1/enterprise-customer-api-credentials/{enterprise_uuid}

suffix = None#
update(request, *args, **kwargs)#

Updates the enterprise API application credentials details for the requesting user.

Method: PUT

URL: /enterprise/api/v1/enterprise-customer-api-credentials/{enterprise_uuid}

enterprise.api.v1.views.enterprise_customer_branding_configuration module#

Views for the enterprise-customer-branding API endpoint.

class enterprise.api.v1.views.enterprise_customer_branding_configuration.EnterpriseCustomerBrandingConfigurationViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the enterprise-customer-branding API endpoint.

FIELDS = ('enterprise_customer__slug',)#
USER_ID_FILTER = 'enterprise_customer__enterprise_customer_users__user_id'#
basename = None#
description = None#
detail = None#
filterset_fields = ('enterprise_customer__slug',)#
lookup_field = 'enterprise_customer__slug'#
name = None#
ordering_fields = ('enterprise_customer__slug',)#
parser_classes = [<class 'rest_framework.parsers.MultiPartParser'>, <class 'rest_framework.parsers.FormParser'>]#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
queryset#
serializer_class#

alias of EnterpriseCustomerBrandingConfigurationSerializer

suffix = None#
update_branding(request, enterprise_uuid)#

PATCH /enterprise/api/v1/enterprise-customer-branding/update_branding/uuid

Requires enterprise customer uuid path parameter

enterprise.api.v1.views.enterprise_customer_catalog module#

Write views for the enterprise-customer-catalog API endpoint.

class enterprise.api.v1.views.enterprise_customer_catalog.EnterpriseCustomerCatalogViewSet(**kwargs)#

Bases: EnterpriseReadOnlyModelViewSet

API Views for performing search through course discovery at the enterprise_catalogs API endpoint.

FIELDS = ('uuid', 'title', 'enterprise_customer', 'enterprise_catalog_query', 'created', 'modified')#
USER_ID_FILTER = 'enterprise_customer__enterprise_customer_users__user_id'#
basename = None#
contains_content_items(request, pk, course_run_ids, program_uuids)#

Return whether or not the EnterpriseCustomerCatalog contains the specified content.

Multiple course_run_ids and/or program_uuids query parameters can be sent to this view to check for their existence in the EnterpriseCustomerCatalog. At least one course run key or program UUID value must be included in the request.

course_detail(request, pk, course_key)#

Return the metadata for the specified course.

The course needs to be included in the specified EnterpriseCustomerCatalog in order for metadata to be returned from this endpoint.

course_run_detail(request, pk, course_id)#

Return the metadata for the specified course run.

The course run needs to be included in the specified EnterpriseCustomerCatalog in order for metadata to be returned from this endpoint.

description = None#
detail = None#
filterset_fields = ('uuid', 'title', 'enterprise_customer', 'enterprise_catalog_query', 'created', 'modified')#
get_serializer_class()#

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

list(request, *args, **kwargs)#
name = None#
ordering_fields = ('uuid', 'title', 'enterprise_customer', 'enterprise_catalog_query', 'created', 'modified')#
program_detail(request, pk, program_uuid)#

Return the metadata for the specified program.

The program needs to be included in the specified EnterpriseCustomerCatalog in order for metadata to be returned from this endpoint.

queryset#
renderer_classes = (<class 'rest_framework.renderers.JSONRenderer'>, <class 'rest_framework_xml.renderers.XMLRenderer'>)#
retrieve(request, *args, **kwargs)#
suffix = None#
class enterprise.api.v1.views.enterprise_customer_catalog.EnterpriseCustomerCatalogWriteViewSet(**kwargs)#

Bases: EnterpriseWriteOnlyModelViewSet

API write only views for the enterprise-customer-catalog API endpoint.

basename = None#
create(request, *args, **kwargs)#

Creates a new EnterpriseCustomerCatalog and returns the created object.

If an EnterpriseCustomerCatalog already exists for the given enterprise_customer and enterprise_catalog_query, returns the existing object.

URL: /enterprise/api/v1/enterprise-customer-catalog/

Method: POST

Payload:

{
  "title":  string - Title of the catalog,
  "enterprise_customer": string - UUID of an existing enterprise customer,
  "enterprise_catalog_query": string - id of an existing enterprise catalog query,
}

Returns 201 if a new EnterpriseCustomerCatalog was created, 200 if an existing EnterpriseCustomerCatalog was

description = None#
detail = None#
has_enterprise_customer_catalog(uuid)#
name = None#
partial_update(request, *args, **kwargs)#

Partially updates only the title in EnterpriseCustomerCatalog and returns the updated object.

URL: /enterprise/api/v1/enterprise-customer-catalog/

Method: PATCH

Payload:

{
  "uuid": string - UUID of an existing enterprise customer catalog,
  "title":  string - Title of the catalog,
}

Returns 200 along with the updated object.

permission_classes = (<class 'rest_framework.permissions.IsAdminUser'>,)#
queryset#
serializer_class#

alias of EnterpriseCustomerCatalogWriteOnlySerializer

suffix = None#

enterprise.api.v1.views.enterprise_customer_invite_key module#

Views for enterprise customer invite keys.

class enterprise.api.v1.views.enterprise_customer_invite_key.EnterpriseCustomerInviteKeyViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API for accessing enterprise customer keys.

authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
basename = None#
basic_list(request, *args, **kwargs)#

Unpaginated list of all invite keys matching the filters.

create(request, *args, **kwargs)#
description = None#
destroy(request, *args, **kwargs)#
detail = None#
filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'enterprise.api.filters.EnterpriseCustomerInviteKeyFilterBackend'>)#
get_serializer_class()#

Use a special serializer for any requests that aren’t read-only.

http_method_names = ['get', 'post', 'patch']#

Post Links user using enterprise_customer_key /enterprise/api/enterprise-customer-invite-key/{enterprise_customer_key}/link-user

Given a enterprise_customer_key, link user to the appropriate enterprise.

If the key is not found, returns 404 If the key is not valid, returns 422 If we create an EnterpriseCustomerUser returns 201 If an EnterpriseCustomerUser if found returns 200

list(request, *args, **kwargs)#
name = None#
partial_update(request, *args, **kwargs)#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
queryset#
retrieve(request, *args, **kwargs)#
suffix = None#

enterprise.api.v1.views.enterprise_customer_members module#

Views for the enterprise-customer-members API endpoint.

class enterprise.api.v1.views.enterprise_customer_members.EnterpriseCustomerMembersPaginator#

Bases: PageNumberPagination

Custom paginator for the enterprise customer members.

get_paginated_response(data)#

Return a paginated style Response object for the given output data.

page_size = 10#
page_size_query_param = 'page_size'#
paginate_queryset(queryset, request, view=None)#

Paginate a queryset if required, either returning a page object, or None if pagination is not configured for this view.

class enterprise.api.v1.views.enterprise_customer_members.EnterpriseCustomerMembersViewSet(**kwargs)#

Bases: EnterpriseReadOnlyModelViewSet

API views for the enterprise-customer-members API endpoint.

basename = None#
description = None#
detail = None#
get_members(request, *args, **kwargs)#

Get all members associated with that enterprise customer

Request Arguments: - enterprise_uuid (URL location, required): The uuid of the enterprise from which learners should be listed.

Optional query params: - user_query (string, optional): Filter the returned members by user name and email with a provided sub-string - sort_by (string, optional): Specify how the returned members should be ordered. Supported sorting values are joined_org, name, and enrollments. - is_reversed (bool, optional): Include to reverse the records in descending order. By default, the results returned are in ascending order. - user_id (string, optional): Specify a user_id in order to fetch a single enterprise customer member, cannot be passed in conjuction with a user_query

name = None#
paginator = <enterprise.api.v1.views.enterprise_customer_members.EnterpriseCustomerMembersPaginator object>#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
queryset#
serializer_class#

alias of EnterpriseMembersSerializer

suffix = None#

enterprise.api.v1.views.enterprise_customer_reporting module#

Views for the Enterprise Customer Reporting API.

class enterprise.api.v1.views.enterprise_customer_reporting.EnterpriseCustomerReportTypesView(**kwargs)#

Bases: APIView

API for getting the report types associated with an enterprise customer

authentication_classes = [<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>]#
get(request, enterprise_uuid)#

Get the dropdown choices for EnterpriseCustomerReportingConfiguration

http_method_names = ['get']#
permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]#
class enterprise.api.v1.views.enterprise_customer_reporting.EnterpriseCustomerReportingConfigurationViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the enterprise-customer-reporting API endpoint.

FIELDS = ('enterprise_customer',)#
USER_ID_FILTER = 'enterprise_customer__enterprise_customer_users__user_id'#
basename = None#
create(request, *args, **kwargs)#
description = None#
destroy(request, *args, **kwargs)#
detail = None#
filterset_fields = ('enterprise_customer',)#
list(request, *args, **kwargs)#
lookup_field = 'uuid'#
name = None#
ordering_fields = ('enterprise_customer',)#
partial_update(request, *args, **kwargs)#
permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]#
queryset#
retrieve(request, *args, **kwargs)#
serializer_class#

alias of EnterpriseCustomerReportingConfigurationSerializer

suffix = None#
update(request, *args, **kwargs)#

enterprise.api.v1.views.enterprise_customer_sso_configuration module#

Views for the enterprise-customer-sso-configuration API endpoint.

exception enterprise.api.v1.views.enterprise_customer_sso_configuration.EnterpriseCustomerInactiveException#

Bases: Exception

Exception raised when an enterprise customer is inactive.

class enterprise.api.v1.views.enterprise_customer_sso_configuration.EnterpriseCustomerSsoConfigurationViewSet(**kwargs)#

Bases: ModelViewSet

API views for the EnterpriseCustomerSsoConfiguration model.

basename = None#
create(request, *args, **kwargs)#
description = None#
destroy(request, *args, **kwargs)#
detail = None#
list(request, *args, **kwargs)#
name = None#
oauth_orchestration_complete(request, configuration_uuid, *args, **kwargs)#

SSO orchestration completion callback. This endpoint is called by the SSO orchestrator when it has completed the configuration process.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
queryset#
retrieve(request, *args, **kwargs)#
serializer_class#

alias of EnterpriseCustomerSsoConfiguration

suffix = None#
update(request, *args, **kwargs)#
exception enterprise.api.v1.views.enterprise_customer_sso_configuration.EntityIdNotFoundError#

Bases: Exception

Exception raised by the SSO configuration api when it fails to fetch a customer IDP’s entity ID from the metadata.

exception enterprise.api.v1.views.enterprise_customer_sso_configuration.SsoConfigurationApiError(*args, **kwargs)#

Bases: RequestException

Exception raised when the Sso configuration api encounters an error while fetching provider metadata.

enterprise.api.v1.views.enterprise_customer_sso_configuration.check_user_part_of_customer(user, enterprise_customer)#

Checks if a user is in an enterprise customer.

enterprise.api.v1.views.enterprise_customer_sso_configuration.fetch_configuration_record(kwargs)#

Fetches the configuration record for the given uuid.

enterprise.api.v1.views.enterprise_customer_sso_configuration.fetch_entity_id_from_metadata_xml(metadata_xml)#

Fetches the entity id from the metadata xml.

enterprise.api.v1.views.enterprise_customer_sso_configuration.fetch_request_data_from_request(request)#

Helper method to fetch the request data dictionary from the request object.

enterprise.api.v1.views.enterprise_customer_sso_configuration.get_customer_from_request(request)#

Gets the enterprise customer from the request or the user.

enterprise.api.v1.views.enterprise_customer_sso_configuration.get_metadata_xml_from_url(url)#

Gets the metadata xml from the given url.

enterprise.api.v1.views.enterprise_customer_support module#

Views for the enterprise-user API endpoint.

class enterprise.api.v1.views.enterprise_customer_support.EnterpriseCustomerSupportPaginator#

Bases: PageNumberPagination

Custom paginator for the enterprise customer support.

get_paginated_response(data)#

Return a paginated style Response object for the given output data.

page_size = 8#
paginate_queryset(queryset, request, view=None)#

Paginate a queryset if required, either returning a page object, or None if pagination is not configured for this view.

class enterprise.api.v1.views.enterprise_customer_support.EnterpriseCustomerSupportViewSet(**kwargs)#

Bases: EnterpriseReadOnlyModelViewSet

API views for the enterprise-customer-support API endpoint.

basename = None#
description = None#
detail = None#
filter_backends = (<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>)#
filter_queryset_by_user_query(queryset)#

Filter queryset based on user provided query

name = None#
ordering_fields = ['is_admin', 'username', 'pending_enterprise_customer']#
paginator = <enterprise.api.v1.views.enterprise_customer_support.EnterpriseCustomerSupportPaginator object>#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
queryset#
retrieve(request, *args, **kwargs)#

Filter down the queryset of groups available to the requesting uuid.

suffix = None#

enterprise.api.v1.views.enterprise_customer_user module#

Views for the enterprise-customer-user API endpoint.

class enterprise.api.v1.views.enterprise_customer_user.EnterpriseCustomerUserViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the enterprise-learner API endpoint.

FIELDS = ('enterprise_customer', 'user_id', 'active')#
basename = None#
description = None#
detail = None#
filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'enterprise.api.filters.EnterpriseCustomerUserFilterBackend'>)#
filterset_fields = ('enterprise_customer', 'user_id', 'active')#
get_serializer_class()#

Use a flat serializer for any requests that aren’t read-only.

name = None#
ordering_fields = ('enterprise_customer', 'user_id', 'active')#
pagination_class#

alias of PaginationWithFeatureFlags

queryset#
suffix = None#

enterprise.api.v1.views.enterprise_group module#

Views for the enterprise-group API endpoint.

class enterprise.api.v1.views.enterprise_group.EnterpriseGroupViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the enterprise-group API endpoint.

assign_learners(request, group_uuid)#

POST /enterprise/api/v1/enterprise-group/<group uuid>/assign_learners

Request Arguments: - learner_emails: List of learner emails to associate with the group. Note: only processes the first 1000 records provided.

Optional request data: - act_by_date (datetime, optional): The expiration date for the subsidy. - catalog_uuid (string, optional): The uuid of the catalog that is part of the subsidy.

Returns: - records_processed: Total number of group membership records processed. - new_learners: Total number of group membership records associated with new pending enterprise learners that were processed. - non_org_rejected: (flex group only) Total number of learner emails rejected because they are not part of the enterprise customer org - existing_learners: Total number of group membership records associated with existing enterprise learners that were processed.

basename = None#
create(request, *args, **kwargs)#

POST /enterprise/api/v1/enterprise-group/

description = None#
detail = None#
filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>)#
get_learners(request, *args, **kwargs)#

Endpoint Location to return all learners: GET api/v1/enterprise-group/<group_uuid>/learners/

Endpoint Location to return pending learners: GET api/v1/enterprise-group/<group_uuid>/learners/?pending_users_only=true

Request Arguments: - group_uuid (URL location, required): The uuid of the group from which learners should be listed.

Optional query params: - pending_users_only (string, optional): Specify that results should only contain pending learners - user_query (string, optional): Filter the returned members by user email and name with a provided sub-string - sort_by (string, optional): Specify how the returned members should be ordered. Supported sorting values are memberDetails, memberStatus, and recentAction. Ordering can be reversed by supplying a - at the beginning of the sorting value ie -memberStatus. - page (int, optional): Which page of paginated data to return. - show_removed (bool, optional): Include removed learners in the response. - is_reversed (bool, optional): Include to reverse the order of returned records. - learners (list[ email strings ], optional): Include to only return member records that are associated with provided emails.

Returns: Paginated list of learners that are associated with the enterprise group uuid:

{
    'count': 1,
    'next': null,
    'previous': null,
    'results': [
        {
            'learner_id': integer or None,
            'pending_enterprise_customer_user_id': integer or None,
            'enterprise_group_membership_uuid': UUID,
            'member_details': {
                'user_email': string,
                'user_name': string,
            },
            'recent_action': string,
            'status': string,
        },
    ],
}
get_queryset(**kwargs)#
  • Filter down the queryset of groups available to the requesting user.

  • Account for requested filtering query params

name = None#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
queryset#
queryset_with_removed#
remove_learners(request, group_uuid)#

POST /enterprise/api/v1/enterprise-group/<group uuid>/remove_learners

Required Arguments:
  • learner_emails:

    List of learner emails to associate with the group.

Optional request data:
  • catalog_uuid (string, optional): The uuid of the catalog that is part of the subsidy.

Returns:

Number of membership records removed

Return type:

  • records_deleted

serializer_class#

alias of EnterpriseGroupSerializer

suffix = None#
update(request, *args, **kwargs)#

PATCH /enterprise/api/v1/enterprise-group/<group uuid>

update_pending_learner_status(request, group_uuid)#

Endpoint location to update the status and errored at time for a pending learner: PATCH api/v1/enterprise-group/<group_uuid>/learners/

Request Arguments: - group_uuid (URL location, required): The uuid of the group which learners should be updated

enterprise.api.v1.views.enterprise_group.remove_group_membership_records(group, catalog_uuid=None, user_emails=None)#

Helper method to take a queryset of membership records, notify associated users of removal from the group, and soft delete the data

params: - group (EnterpriseGroup record, required): the Django ORM record related to the group from which members will be removed - catalog_uuid (UUID string, optional): Catalog UUID string used to email learners informing them of their removal. If no catalog is supplied, email reminders will not be sent. - user_emails (array[email strings], optional): List of user emails. If supplied, this method will remove membership records related to ecu and pecu objects containing provided emails.

enterprise.api.v1.views.enterprise_group_membership module#

Views for the enterprise-group-membership API endpoint.

class enterprise.api.v1.views.enterprise_group_membership.EnterpriseGroupMembershipViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the enterprise-group-membership API endpoint.

basename = None#
description = None#
detail = None#
filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>)#
get_flex_group_memberships(request)#

Endpoint that filters flex group memberships by lms_user_id and enterprise_uuid.

Parameters: - lms_user_id (str): Filter results by the LMS user ID. - enterprise_uuid (str): Filter results by the Enterprise UUID.

Response: - Returns a list of EnterpriseGroupMemberships matching the filters. - Response format: JSON array of serialized EnterpriseGroupMembership objects.

name = None#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
queryset#
serializer_class#

alias of EnterpriseGroupMembershipSerializer

suffix = None#

enterprise.api.v1.views.enterprise_sso_users module#

Views for the enterprise-sso-user-info API endpoint.

class enterprise.api.v1.views.enterprise_sso_users.EnterpriseSSOUserViewSet(**kwargs)#

Bases: ViewSet

API views for Enterprise SSO user operations.

Provides endpoints for retrieving Enterprise SSO user details.

basename = None#
description = None#
detail = None#
name = None#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
suffix = None#
user_details(request)#

Retrieve Enterprise SSO user details.

Query Parameters:
  • org_id: ID of the organization to retrieve Enterprise Customer

  • external_user_id: ID of the user to get details for

Returns:

Response with Enterprise SSO user details

enterprise.api.v1.views.enterprise_subsidy_fulfillment module#

Views for the Enterprise Subsidy Fulfillment API.

exception enterprise.api.v1.views.enterprise_subsidy_fulfillment.EnrollmentModificationException#

Bases: Exception

An exception that represents an error when modifying the state of an enrollment via the EnrollmentApiClient.

class enterprise.api.v1.views.enterprise_subsidy_fulfillment.EnterpriseSubsidyFulfillmentViewSet(**kwargs)#

Bases: PermissionRequiredMixin, EnterpriseWrapperApiViewSet

General API views for subsidized enterprise course enrollments.

Supported operations:
  • Fetch a subsidy fulfillment record by uuid.

    /enterprise/api/v1/enterprise-subsidy-fulfillment/{fulfillment_source_uuid}/

  • Cancel a subsidy fulfillment enrollment record by uuid.

    /enterprise/api/v1/enterprise-subsidy-fulfillment/{fulfillment_source_uuid}/cancel-fulfillment/

  • Fetch all unenrolled subsidy fulfillment records.

    /enterprise/api/v1/operator/enterprise-subsidy-fulfillment/unenrolled/

Cancel and fetch endpoints require a fulfillment source uuid query parameter. Fetching unenrollments supports an optional unenrolled_after query parameter to filter the returned queryset down to only enterprise enrollments unenrolled after the supplied datetime.

Arguments (Fetch & Cancel):

fulfillment_source_uuid (str): The uuid of the subsidy fulfillment record.

Arguments (Unenrolled):

unenrolled_after (str): A datetime string. Only return enrollments unenrolled after this time.

Returns (Fetch):

(Response): JSON response containing the subsidy fulfillment record.

Returns (Unenrolled):

(Response): JSON list response containing the unenrolled subsidy fulfillment records.

api_response = [
    {
        enterprise_course_enrollment: {
            enterprise_customer_user: <user_id>,
            course_id: <course_id>,
            unenrolled: <datetime>
            created: <datetime>
        }
        license_uuid/transaction_id: <uuid>,
        uuid: <uuid>,
    },
]
Raises

(Http404): If the subsidy fulfillment record does not exist or if subsidy fulfillment exists under a separate enterprise. (Http403): If the requesting user does not have the appropriate permissions. (EnrollmentModificationException): If something goes wrong while updating the platform CourseEnrollment object.

basename = None#
cancel_enrollment(request, fulfillment_source_uuid)#

Cancel a single subsidized enrollment. Assumes fulfillment source has a valid enterprise enrollment. /enterprise/api/v1/enterprise-subsidy-fulfillment/{fulfillment_source_uuid}/cancel-fulfillment/

description = None#
detail = None#
get_permission_object()#

Depending on the requested view, returns a record identifier to check perms against.

get_permission_required()#

Return specific permission name based on the view being requested

get_subsidy_fulfillment_serializer_class()#

Fetch the correct serializer class based on the subsidy type.

get_unenrolled_fulfillment_serializer_class()#

Fetch the correct recently unenrolled serializer class based on provided querysets.

name = None#
requested_fulfillment_source#

Computes and caches the requested fulfillment source record for this request.

retrieve(request, fulfillment_source_uuid, *args, **kwargs)#
Retrieve a single subsidized enrollment.

/enterprise/api/v1/subsidy-fulfillment/{fulfillment_source_uuid}/

suffix = None#
unenrolled(request, *args, **kwargs)#
List all unenrolled subsidy fulfillments.

/enterprise/api/v1/operator/enterprise-subsidy-fulfillment/unenrolled/

Parameters:
  • modified (str) – A datetime string. Only return enrollments modified after this time.

  • retrieve_licensed_enrollments (bool) – If true, return data related to licensed enrollments instead of learner credit

class enterprise.api.v1.views.enterprise_subsidy_fulfillment.LicensedEnterpriseCourseEnrollmentViewSet(**kwargs)#

Bases: EnterpriseWrapperApiViewSet

API views for the licensed-enterprise-course-enrollment API endpoint.

class EnrollmentTerminationStatus#

Bases: object

Defines statuses related to enrollment states during the course unenrollment process.

COURSE_COMPLETED = 'course already completed'#
MOVED_TO_AUDIT = 'moved to audit'#
UNENROLLED = 'unenrolled'#
UNENROLL_FAILED = 'unenroll_user_from_course returned false.'#
OPT_IGNORE_ENROLLMENTS_MODIFIED_AFTER_PARAM = 'ignore_enrollments_modified_after'#
REQ_EXP_LICENSE_UUIDS_PARAM = 'expired_license_uuids'#
basename = None#
bulk_licensed_enrollments_expiration(request)#

Changes the mode for licensed enterprise course enrollments to the “audit” course mode, or unenroll the user if no audit mode exists for each expired license uuid

Parameters:
  • expired_license_uuids – The expired license uuids.

  • ignore_enrollments_modified_after – All course enrollments modified past this given date will be ignored, i.e. the enterprise subscription plan expiration date.

description = None#
detail = None#
license_revoke(request, *args, **kwargs)#

Changes the mode for a user’s licensed enterprise course enrollments to the “audit” course mode, or unenroll the user if no audit mode exists for a given course.

Will return a response with status 200 if no errors were encountered while modifying the course enrollment, or a 422 if any errors were encountered. The content of the response is of the form:

{
    'course-v1:puppies': {'success': true, 'message': 'unenrolled'},
    'course-v1:birds': {'success': true, 'message': 'moved to audit'},
    'course-v1:kittens': {'success': true, 'message': 'course already completed'},
    'course-v1:snakes': {'success': false, 'message': 'unenroll_user_from_course returned false'},
    'course-v1:lizards': {'success': false, 'message': 'Some other exception'},
}

The first four messages are the values of constants that a client may expect to receive and parse accordingly.

name = None#
queryset#
serializer_class#

alias of LicensedEnterpriseCourseEnrollmentReadOnlySerializer

suffix = None#

enterprise.api.v1.views.notifications module#

Views for the Admin Notification API.

class enterprise.api.v1.views.notifications.NotificationReadView(**kwargs)#

Bases: APIView

API to mark notifications as read.

MISSING_REQUIRED_PARAMS_MSG = 'Some required parameter(s) missing: {}'#
REQUIRED_PARAM_ENTERPRISE_SLUG = 'enterprise_slug'#
REQUIRED_PARAM_NOTIFICATION_ID = 'notification_id'#
authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
get_missing_params_message(parameter_state)#

Get a user-friendly message indicating a missing parameter for the API endpoint.

get_required_query_params(request)#

Gets notification_id and enterprise_slug. which are the relevant parameters for this API endpoint.

Parameters:

request – The request to this endpoint.

Returns:

The notification_id and enterprise_slug from the request.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
post(request)#

POST /enterprise/api/v1/read_notification

Requires a JSON object of the following format:

{
    'notification_id': 1,
    'enterprise_slug': 'enterprise_slug',
}
Keys:
  • notification_id – Notification ID which is read by Current User.

  • enterprise_slug – The slug of the enterprise.

throttle_classes = (<class 'enterprise.api.throttles.ServiceUserThrottle'>,)#

enterprise.api.v1.views.pending_enterprise_customer_admin_user module#

Views for the pending-enterprise-customer-admin-user API endpoint.

class enterprise.api.v1.views.pending_enterprise_customer_admin_user.PendingEnterpriseCustomerAdminUserViewSet(**kwargs)#

Bases: PermissionRequiredMixin, EnterpriseReadWriteModelViewSet

API views for the pending-enterprise-customer-admin-user API endpoint. Requires staff permissions

FIELDS = ('enterprise_customer', 'user_email')#
basename = None#
description = None#
detail = None#
filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>)#
filterset_fields = ('enterprise_customer', 'user_email')#
name = None#
ordering_fields = ('enterprise_customer', 'user_email')#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
permission_required = 'provisioning.has_pending_enterprise_customer_admin_access'#
queryset#
serializer_class#

alias of PendingEnterpriseCustomerAdminUserSerializer

suffix = None#

enterprise.api.v1.views.pending_enterprise_customer_user module#

Views for the pending-enterprise-customer-user API endpoint.

class enterprise.api.v1.views.pending_enterprise_customer_user.PendingEnterpriseCustomerUserEnterpriseAdminViewSet(**kwargs)#

Bases: PendingEnterpriseCustomerUserViewSet

Viewset for allowing enterprise admins to create linked learners Endpoint url: link_pending_enterprise_users/(?P<enterprise_uuid>[A-Za-z0-9-]+)/?$ Admin must be an administrator for the enterprise in question

basename = None#
description = None#
detail = None#

Creates a PendingEnterpriseCustomerUser if no EnterpriseCustomerUser for the given (customer, email) combination(s) exists. Can accept one user or a list of users.

Returns 201 if any users were created, 204 if no users were created.

name = None#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
serializer_class#

alias of LinkLearnersSerializer

suffix = None#
class enterprise.api.v1.views.pending_enterprise_customer_user.PendingEnterpriseCustomerUserViewSet(**kwargs)#

Bases: EnterpriseReadWriteModelViewSet

API views for the pending-enterprise-learner API endpoint. Requires staff permissions

FIELDS = ('enterprise_customer', 'user_email')#
UNIQUE = 'unique'#
USER_EXISTS_ERROR = 'EnterpriseCustomerUser record already exists'#
basename = None#
create(request, *args, **kwargs)#

Creates a PendingEnterpriseCustomerUser if no EnterpriseCustomerUser for the given (customer, email) combination(s) exists. Can accept one user or a list of users.

Returns 201 if any users were created, 204 if no users were created.

description = None#
detail = None#
filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>)#
filterset_fields = ('enterprise_customer', 'user_email')#
name = None#
ordering_fields = ('enterprise_customer', 'user_email')#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'rest_framework.permissions.IsAdminUser'>)#
queryset#
serializer_class#

alias of PendingEnterpriseCustomerUserSerializer

suffix = None#

enterprise.api.v1.views.saml_provider_config module#

Viewset for enterprise SAML provider config administration.

class enterprise.api.v1.views.saml_provider_config.SAMLProviderConfigViewSet(**kwargs)#

Bases: PermissionRequiredMixin, ModelViewSet

A View to handle SAMLProviderConfig CRUD for enterprise admin users.

Usage:

GET  /auth/saml/v0/provider_config/?enterprise_customer_uuid=<uuid>
POST /auth/saml/v0/provider_config/
PATCH /auth/saml/v0/provider_config/<pk>/
DELETE /auth/saml/v0/provider_config/<pk>/
basename = None#
create(request, *args, **kwargs)#

Process POST /auth/saml/v0/provider_config/ {postData}

description = None#
destroy(request, *args, **kwargs)#
detail = None#
get_permission_object()#

Retrieve an EnterpriseCustomer uuid to do auth against.

get_queryset()#

Find and return the matching providerconfig for the given enterprise uuid if an association exists in EnterpriseCustomerIdentityProvider model.

get_serializer_class()#

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

name = None#
permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]#
permission_required = 'enterprise.can_access_admin_dashboard'#
property requested_enterprise_uuid#

The enterprise customer uuid from request params or post body.

suffix = None#

enterprise.api.v1.views.saml_provider_data module#

Viewset for enterprise SAML provider data administration.

class enterprise.api.v1.views.saml_provider_data.SAMLProviderDataViewSet(**kwargs)#

Bases: PermissionRequiredMixin, ModelViewSet

A View to handle SAMLProviderData CRUD for enterprise admin users.

Usage:

GET  /auth/saml/v0/provider_data/?enterprise_customer_uuid=<uuid>
POST /auth/saml/v0/provider_data/
PATCH /auth/saml/v0/provider_data/<pk>/
DELETE /auth/saml/v0/provider_data/<pk>/
POST /auth/saml/v0/provider_data/sync_provider_data
basename = None#
description = None#
detail = None#
get_permission_object()#

Retrieve an EnterpriseCustomer to do auth against.

get_queryset()#

Find and return the matching providerid for the given enterprise uuid.

Note: There is no direct association between samlproviderdata and enterprisecustomer. So we make that association in code via samlproviderdata > samlproviderconfig (via entity_id) then, we fetch enterprisecustomer via samlproviderconfig > enterprisecustomer (via association table).

get_serializer_class()#

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

name = None#
permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]#
permission_required = 'enterprise.can_access_admin_dashboard'#
property requested_enterprise_uuid#

The enterprise customer uuid from request params or post body.

suffix = None#
sync_provider_data(request)#

Fetch and sync SAML provider metadata from the configured metadata URL.

enterprise.api.v1.views.saml_utils module#

Utility functions for SAML provider administration.

Migrated from openedx-platform’s third_party_auth/utils.py since they are only used by the SAML admin viewsets now hosted in edx-enterprise.

exception enterprise.api.v1.views.saml_utils.SAMLMetadataURLError#

Bases: Exception

A SAML metadata URL failed security validation.

enterprise.api.v1.views.saml_utils.convert_saml_slug_provider_id(provider)#

Provider id is stored with the backend type prefixed to it (ie “saml-“) Slug is stored without this prefix. This just converts between them whenever you expect the opposite of what you currently have.

Parameters:

provider (string) – provider_id or slug

Returns:

Opposite of what you inputted (slug -> provider_id; provider_id -> slug)

Return type:

(string)

enterprise.api.v1.views.saml_utils.fetch_metadata_xml(url)#

Fetches IDP metadata from provider url Returns: xml document

enterprise.api.v1.views.saml_utils.validate_saml_metadata_url(url)#

Validate that a SAML metadata URL is safe to fetch.

Enforces HTTPS and blocks requests to loopback, link-local, and reserved IP addresses. Link-local specifically covers cloud instance metadata endpoints (169.254.0.0/16, e.g. the AWS metadata service at 169.254.169.254). Reserved addresses (e.g. 240.0.0.0/4) are IETF-assigned ranges that are never routable on real networks.

Private IP ranges (RFC 1918: 10.x, 172.16.x, 192.168.x) are also blocked by default, since most Open edX deployments fetch SAML metadata from public IdPs. Operators running in a private network where the SAML IdP has a private IP can opt out by setting SAML_METADATA_URL_ALLOW_PRIVATE_IPS = True in Django settings.

Limitation: IP address checks only apply to literal IPs in the URL. Hostname- based URLs are not validated against the IP blocklists. Operators are encouraged to complement this with network-level egress filtering that blocks outbound connections from the Open edX server to link-local (169.254.0.0/16) and RFC 1918 private address ranges.

Raises SAMLMetadataURLError if the URL fails validation.

enterprise.api.v1.views.saml_utils.validate_uuid4_string(uuid_string)#

Returns True if valid uuid4 string, or False

Module contents#

API views for the enterprise app.