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 generate a signed token for an enterprise admin to use Plotly analytics.

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)#

Generate auth token for plotly.

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.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.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)#

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

filter_backends = (<class 'rest_framework.filters.OrderingFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'enterprise.api.filters.UserFilterBackend'>, <class 'enterprise.api.filters.EnterpriseLinkedUserFilterBackend'>)#
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_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#
throttle_classes = (<class 'enterprise.api.throttles.HighServiceUserThrottle'>,)#

Enables/Disables universal link config.

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_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_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_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. - 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 - q (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.

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_learner_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>

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: EnterpriseWrapperApiViewSet

General API views for subsidized enterprise course enrollments.

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

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

  • Cancel a subsidy fulfillment enrollment record by uuid.

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

  • Fetch all unenrolled subsidy fulfillment records.

    /enterprise/api/v1/operator/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/subsidy-fulfillment/{fulfillment_source_uuid}/cancel-enrollment/

description = None#
detail = None#
get_subsidy_fulfillment_queryset()#

Return the queryset for this view. Queries across subsidy types until it finds a match for the provided uuid. Returns a 404 if no subsidy fulfillment record is found.

get_subsidy_fulfillment_serializer_class()#

Fetch the correct serializer class based on the subsidy type.

get_unenrolled_fulfillment_queryset()#

Return the queryset for unenrolled subsidy fulfillment records. Applies a modified timestamp filter to fetch records modified after if provided from query params.

get_unenrolled_fulfillment_serializer_class()#

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

name = None#
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_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.plotly_auth module#

Views for Plotly auth.

class enterprise.api.v1.views.plotly_auth.PlotlyAuthView(**kwargs)#

Bases: GenericAPIView

API to generate a signed token for an enterprise admin to use Plotly analytics.

get(request, enterprise_uuid)#

Generate auth token for plotly.

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

Module contents#

API views for the enterprise app.