Decorators for Enterprise API views.
Ensure at least one of the specified query parameters are included in the request.
This decorator checks for the existence of at least one of the specified query parameters and passes the values as function parameters to the decorated view. If none of the specified query parameters are included in the request, a ValidationError is raised.
Usage:
@require_at_least_one_query_parameter('program_uuids', 'course_run_ids')
def my_view(request, program_uuids, course_run_ids):
# Some functionality ...
Fields for Enterprise API serializers.
Bases: rest_framework.fields.Field
Serializers a Base64 encoded CSV with emails into an array of emails
Transform the incoming primitive data into a native value.
Transform the outgoing native value into primitive data.
Custom API permissions.
Bases: rest_framework.permissions.BasePermission
Find out if the requesting user belongs to a django group meant for granting access to an enterprise feature. This check applies to both staff and non-staff users.
Return True if permission is granted, False otherwise.
Serializers for enterprise api version 1.
Bases: rest_framework.serializers.ModelSerializer
Serializer for AdminNotification model.
Bases: object
alias of enterprise.models.AdminNotification
Bases: rest_framework.serializers.ModelSerializer
Base serializer for writing to the EnterpriseCustomerInviteKey model.
Bases: enterprise.api.v1.serializers.ImmutableStateSerializer
Serializer for course data retrieved from the discovery service course detail API endpoint.
This serializer updates the course and course run data with the EnterpriseCustomer-specific enrollment page URL for the given course and course runs.
Bases: enterprise.api.v1.serializers.ImmutableStateSerializer
Serializer for course run data retrieved from the discovery service course_run detail API endpoint.
This serializer updates the course run data with the EnterpriseCustomer-specific enrollment page URL for the given course run.
Bases: rest_framework.serializers.ModelSerializer
Serializer for EnterpriseCourseEnrollment model.
Bases: rest_framework.serializers.ModelSerializer
Serializer for writing to the EnterpriseCourseEnrollment model.
Save the model with the found EnterpriseCustomerUser.
Verify that the username has a matching user, and that the user has an associated EnterpriseCustomerUser.
Bases: rest_framework.serializers.ModelSerializer
Serializer for EnterpriseCustomer model only for name and id fields.
Bases: object
alias of enterprise.models.EnterpriseCustomer
Bases: rest_framework.serializers.ModelSerializer
Serializer for EnterpriseCustomerBrandingConfiguration model.
Bases: object
alias of enterprise.models.EnterpriseCustomerBrandingConfiguration
Return a string representation of the associated enterprise customer’s UUID.
Return the slug of the associated enterprise customer.
Use EnterpriseCustomerBrandingConfiguration.safe_logo_url to return an absolute URL for either the saved customer logo or the platform logo by default
Return the primary color of the branding config OR the default primary color code
Return the secondary color of the branding config OR the default secondary color code
Return the tertiary color of the branding config OR the default tertiary color code
Bases: rest_framework.serializers.Serializer
Serializes a email_csv or email field for bulk enrollment requests.
Bases: rest_framework.serializers.Serializer
Serializes a licenses info field for bulk enrollment requests.
Bases: enterprise.api.v1.serializers.EnterpriseCustomerCatalogSerializer
Serializer for the EnterpriseCustomerCatalog
model which includes
the catalog’s discovery service search query results.
Serialize the EnterpriseCustomerCatalog object.
instance (EnterpriseCustomerCatalog) – The EnterpriseCustomerCatalog to serialize.
The EnterpriseCustomerCatalog converted to a dict.
Bases: rest_framework.serializers.ModelSerializer
Serializer for the EnterpriseCustomerCatalog
model.
Bases: rest_framework.serializers.ListSerializer
Serializes a list of enrollment requests.
Meant to be used in conjunction with EnterpriseCustomerCourseEnrollmentsSerializer.
This selectively calls the child create method based on whether or not validation failed for each payload.
This implements the same relevant logic as ListSerializer except that if one or more items fail validation, processing for other items that did not fail will continue.
This selectively calls to_representation on each result that was processed by create.
Bases: rest_framework.serializers.Serializer
Serializes enrollment information for a collection of students/emails.
This is mainly useful for implementing validation when performing enrollment operations.
Bases: object
alias of enterprise.api.v1.serializers.EnterpriseCustomerCourseEnrollmentsListSerializer
Perform the enrollment for existing enterprise customer users, or create the pending objects for new users.
Validate that at least one of the user identifier fields has been passed in.
Validates that the course run id is part of the Enterprise Customer’s catalog.
Validates the lms_user_id, if is given, to see if there is an existing EnterpriseCustomerUser for it.
Validates the tpa_user_id, if is given, to see if there is an existing EnterpriseCustomerUser for it.
It first uses the third party auth api to find the associated username to do the lookup.
Validates the user_email, if given, to see if an existing EnterpriseCustomerUser exists for it.
If it does not, it does not fail validation, unlike for the other field validation methods above.
Bases: rest_framework.serializers.ModelSerializer
Serializer for EnterpriseCustomerIdentityProvider model.
Bases: object
alias of enterprise.models.EnterpriseCustomerIdentityProvider
Bases: rest_framework.serializers.ModelSerializer
Serializer for updating the EnterpriseCustomerInviteKey model.
Bases: enterprise.api.v1.serializers.BaseEnterpriseCustomerInviteKeySerializer
Serializer for reading the EnterpriseCustomerInviteKey model.
Bases: enterprise.api.v1.serializers.BaseEnterpriseCustomerInviteKeySerializer.Meta
Bases: enterprise.api.v1.serializers.BaseEnterpriseCustomerInviteKeySerializer
Serializer for writing to the EnterpriseCustomerInviteKey model.
Validates an EnterpriseCustomer with the given enterprise_customer_uuid exists.
Bases: rest_framework.serializers.ModelSerializer
Serializer for EnterpriseCustomerReportingConfiguration model.
Bases: object
alias of enterprise.models.EnterpriseCustomerReportingConfiguration
Perform the creation of model instance and link the enterprise customer catalogs.
validated_data (dict) – A dictionary containing serializer’s validated data.
reporting configuration.
Update the instance of enterprise customer reporting configuration and link the enterprise customer catalogs.
instance (EnterpriseCustomerReportingConfiguration) – Instance of the enterprise customer reporting configuration being updated.
validated_data (dict) – A dictionary containing serializer’s validated data.
reporting configuration.
Bases: rest_framework.serializers.ModelSerializer
Serializer for EnterpriseCustomer model.
Bases: object
alias of enterprise.models.EnterpriseCustomer
Return the serialized branding configuration object OR default object if null
Return list of catalog uuids associated with the enterprise customer.
Return the notification text if exist OR None
Bases: rest_framework.serializers.Serializer
Serializer for toggling an EnterpriseCustomer enable_universal_link field.
Bases: rest_framework.serializers.Serializer
Serializer for the EnterpriseCustomerViewSet
unlink_users action.
Bases: rest_framework.serializers.ModelSerializer
Serializer for EnterpriseCustomerUser model.
Bases: object
Return serialization of EnterpriseCustomerUser.data_sharing_consent_records property.
EnterpriseCustomerUser – The EnterpriseCustomerUser.
The serialized DataSharingConsent records associated with the EnterpriseCustomerUser.
list of dict
Return the enterprise related django groups that this user is a part of.
Return the enterprise role assignments for this enterprise customer user.
Bases: rest_framework.serializers.ModelSerializer
Serializer for writing to the EnterpriseCustomerUser model.
Save the EnterpriseCustomerUser.
Verify that the username has a matching user.
Bases: rest_framework.serializers.Serializer
Base serializer for any serializer that inhibits state changing requests.
Do not perform any operations for state changing requests.
Do not perform any operations for state changing requests.
Bases: rest_framework.serializers.ModelSerializer
Serializer for LicensedEnterpriseCourseEnrollment model.
Bases: object
alias of enterprise.models.LicensedEnterpriseCourseEnrollment
Bases: rest_framework.serializers.Serializer
Nested serializer class to allow for many license info dictionaries.
Bases: enterprise.api.v1.serializers.PendingEnterpriseCustomerUserSerializer
Extends the PendingEnterpriseCustomerSerializer to validate that the enterprise customer uuid matches the uuid the user has permissions to update
Check that the enterprise customer is the same as the one the user has permissions for The value recieved is an EnterpriseCustomer object
Bases: rest_framework.serializers.ModelSerializer
Serializer for writing to the PendingEnterpriseCustomerUser model.
Create the PendingEnterpriseCustomerUser, or EnterpriseCustomerUser if a user with the validated_email already exists.
Because we are returning whether or not the instance was created from the create method, we must use the instance for to_representation and ignore the “created” half of the tuple
Bases: enterprise.api.v1.serializers.ImmutableStateSerializer
Serializer for program data retrieved from the discovery service program detail API endpoint.
This serializer updates the program data and child course run data with EnterpriseCustomer-specific enrollment page URLs for the given content types.
Bases: enterprise.api.v1.serializers.ImmutableStateSerializer
Serializer for responses that require pagination.
Bases: rest_framework.serializers.ModelSerializer
Serializer for Site model.
Bases: object
alias of django.contrib.sites.models.Site
Bases: rest_framework.serializers.ModelSerializer
Serializer for User model.
Bases: object
alias of django.contrib.auth.models.User
URL definitions for enterprise api version 1 endpoint.
Views for enterprise api version 1 endpoint.
Bases: rest_framework.views.APIView
View for enterprise catalog query. This will be called from django admin tool to populate content_filter field of EnterpriseCustomerCatalog model.
API endpoint for fetching an enterprise catalog query.
Bases: rest_framework.views.APIView
API to request coupon codes.
Get a user-friendly message indicating a missing parameter for the API endpoint.
Gets email
, enterprise_name
, number_of_codes
, and notes
,
which are the relevant parameters for this API endpoint.
request – The request to this endpoint.
The email
, enterprise_name
, number_of_codes
and notes
from the 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",
}
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.
Bases: Exception
An exception that represents an error when modifying the state of an enrollment via the EnrollmentApiClient.
Bases: enterprise.api.v1.views.EnterpriseReadWriteModelViewSet
API views for the enterprise-course-enrollment
API endpoint.
Use a special serializer for any requests that aren’t read-only.
Bases: enterprise.api.v1.views.EnterpriseReadWriteModelViewSet
API views for the enterprise-customer-branding
API endpoint.
alias of enterprise.api.v1.serializers.EnterpriseCustomerBrandingConfigurationSerializer
PATCH /enterprise/api/v1/enterprise-customer-branding/update_branding/uuid
Requires enterprise customer uuid path parameter
Bases: enterprise.api.v1.views.EnterpriseReadOnlyModelViewSet
API Views for performing search through course discovery at the enterprise_catalogs
API endpoint.
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.
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.
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.
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)
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.
Bases: enterprise.api.v1.views.EnterpriseReadWriteModelViewSet
API for accessing enterprise customer keys.
Unpaginated list of all invite keys matching the filters.
Use a special serializer for any requests that aren’t read-only.
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
Bases: rest_framework.views.APIView
API for getting the report types associated with an enterprise customer
Get the dropdown choices for EnterpriseCustomerReportingConfiguration
Bases: enterprise.api.v1.views.EnterpriseReadWriteModelViewSet
API views for the enterprise-customer-reporting
API endpoint.
alias of enterprise.api.v1.serializers.EnterpriseCustomerReportingConfigurationSerializer
Bases: enterprise.api.v1.views.EnterpriseReadWriteModelViewSet
API views for the enterprise-learner
API endpoint.
Use a flat serializer for any requests that aren’t read-only.
Bases: enterprise.api.v1.views.EnterpriseReadWriteModelViewSet
API views for the enterprise-customer
API endpoint.
Enterprise Customer’s Basic data list without pagination
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.
Creates a course enrollment for an EnterpriseCustomerUser.
Supports listing dashboard enterprises for frontend-app-admin-portal.
Creates a set of licensed enterprise_learners by bulk enrolling them in all specified courses. This endpoint is not transactional, in that any one or more failures will not affect other successful enrollments made within the same request.
licenses_info (list of dicts) –
an array of dictionaries, each containing the necessary information to create a licenced enrollment for a user in a specified course. Each dictionary must contain a user email, a course run key, and a UUID of the license that the learner is using to enroll with.
Example:
licenses_info: [
{
'email': 'newuser@test.com',
'course_run_key': 'course-v1:edX+DemoX+Demo_Course',
'license_uuid': '5b77bdbade7b4fcb838f8111b68e18ae',
},
...
]
discount (int) – the percent discount to be applied to all enrollments. Defaults to 100.
- All users exist and are enrolled -
{‘successes’: [], ‘pending’: [], ‘failures’: []}, 201
- Some or none of the users exist but are enrolled -
{‘successes’: [], ‘pending’: [], ‘failures’: []}, 202
{‘successes’: [], ‘pending’: [], ‘failures’: []}, 409
{‘successes’: [], ‘pending’: [], ‘failures’: [] ‘invalid_email_addresses’: []}, 409
Success cases
Instantiates and returns the list of permissions that this view requires.
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)
alias of enterprise.api.v1.serializers.EnterpriseCustomerSerializer
Enables/Disables universal link config.
Unlinks users with the given emails from the enterprise.
Returns the list of enterprise customers the user has a specified group permission access to.
Bases: enterprise.api.v1.views.EnterpriseViewSet
Base class for attribute and method definitions common to all view sets.
Bases: enterprise.api.v1.views.EnterpriseModelViewSet
, rest_framework.viewsets.ReadOnlyModelViewSet
Base class for all read only Enterprise model view sets.
Bases: enterprise.api.v1.views.EnterpriseModelViewSet
, rest_framework.viewsets.ModelViewSet
Base class for all read/write Enterprise model view sets.
Bases: object
Base class for all Enterprise view sets.
Ensure that the wrapped API client’s response brings us valid data. If not, raise an error and log it.
Bases: enterprise.api.v1.views.EnterpriseViewSet
, rest_framework.viewsets.ViewSet
Base class for attribute and method definitions common to all view sets which wrap external APIs.
Bases: enterprise.api.v1.views.EnterpriseWrapperApiViewSet
API views for the licensed-enterprise-course-enrollment
API endpoint.
Bases: object
Defines statuses related to enrollment states during the course unenrollment process.
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
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.
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.
alias of enterprise.api.v1.serializers.LicensedEnterpriseCourseEnrollmentReadOnlySerializer
Bases: rest_framework.views.APIView
API to mark notifications as read.
Get a user-friendly message indicating a missing parameter for the API endpoint.
Gets notification_id
and enterprise_slug
.
which are the relevant parameters for this API endpoint.
request – The request to this endpoint.
The notification_id
and enterprise_slug
from the request.
POST /enterprise/api/v1/read_notification
Requires a JSON object of the following format:
{
'notification_id': 1,
'enterprise_slug': 'enterprise_slug',
}
notification_id – Notification ID which is read by Current User.
enterprise_slug – The slug of the enterprise.
Bases: enterprise.api.v1.views.PendingEnterpriseCustomerUserViewSet
Viewset for allowing enterpise 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
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.
alias of enterprise.api.v1.serializers.LinkLearnersSerializer
Bases: enterprise.api.v1.views.EnterpriseReadWriteModelViewSet
API views for the pending-enterprise-learner
API endpoint.
Requires staff permissions
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.
alias of enterprise.api.v1.serializers.PendingEnterpriseCustomerUserSerializer
Bases: rest_framework.generics.GenericAPIView
API to authenticate user with Tableau.
Get the auth token against logged in user from tableau
API endpoint for enterprise app.