Base API clients to comunicate with edx services.
Bases: object
API client mixin.
Bases: enterprise.api_client.client.APIClientMixin
API client based on OAuthAPIClient to cummunicate with edx services.
Uses the backend service user to make requests.
Bases: enterprise.api_client.client.APIClientMixin
API client based on requests.Session to cummunicate with edx services.
Used to call APIs which don’t require authentication.
Bases: enterprise.api_client.client.APIClientMixin
API client based on requests.Session to cummunicate with edx services.
Requires user object to instantiate the client with the jwt token authentication.
Connect to the REST API, authenticating with a JWT for the current user.
Use this method decorator to ensure the JWT token is refreshed when needed.
Return True if the JWT token has expired, False if not.
Utilities to get details from the course catalog API.
Bases: enterprise.api_client.client.UserAPIClient
The API client to make calls to the Catalog API.
Return results from the cache or discovery service’s search/all endpoint.
Paginated response or all the records.
Return results from the discovery service’s search/all endpoint.
Return the course and course run metadata for the given course run ID.
Return the details of a single course by id - not a course run id.
Return the course id for the given course identifier. The course_identifier may be a course id or a course run id; in either case the course id will be returned.
The ‘course id’ is the identifier for a course (ex. edX+DemoX) The ‘course run id’ is the identifier for a run of a course (ex. edX+DemoX+demo_run)
Return course_run data, including name, ID and seats.
course_run_id (string) – Course run ID (aka Course Key) in string format.
Course run data provided by Course Catalog API.
Return all course and course run keys and uuids for the specified course run id
Return single program by UUID, or None if not found.
program_uuid (string) – Program UUID in string form
Program data provided by Course Catalog API
Get a list of the course IDs (not course run IDs) contained in the program.
Get a program type by its slug.
Traverse a paginated API response and extracts and concatenates “results” returned by API.
Bases: enterprise.api_client.discovery.CourseCatalogApiClient
Catalog API client which uses the configured Catalog service user.
Get whether the program exists or not.
Bases: enterprise.api_client.client.NoAuthAPIClient
Class to build a course discovery client to make calls to the discovery service.
Returns an instance of the CourseCatalogApiServiceClient
site – (Site)
(CourseCatalogServiceClient)
Client for communicating with the E-Commerce API.
Bases: object
The API client to make calls to the E-Commerce API.
Calls ecommerce to create orders for the manual enrollments passed in.
enrollments should be a list of enrollments with the following format:
{
"lms_user_id": <int>,
"username": <str>,
"email": <str>,
"course_run_key": <str>
}
Since student.CourseEnrollment lives in LMS, we’re just passing around dicts of the relevant information.
Bases: enterprise.api_client.client.NoAuthAPIClient
The E-Commerce API client without authentication.
Client for communicating with the Enterprise API.
Bases: enterprise.api_client.client.UserAPIClient
The API client to make calls to the Enterprise API.
Return all content metadata contained in the catalogs associated with the EnterpriseCustomer.
enterprise_customer (EnterpriseCustomer) – The EnterpriseCustomer to return content metadata for.
enterprise_catalogs (EnterpriseCustomerCatalog) – Optional list of EnterpriseCustomerCatalog objects.
List of dicts containing content metadata.
Client for communicating with the Enterprise API.
Bases: enterprise.api_client.client.UserAPIClient
The API client to make calls to the Enterprise Catalog API.
Checks whether an enterprise catalog contains the given content.
The enterprise catalog endpoint does not differentiate between course_run_ids and program_uuids so they can be used interchangeably. The two query parameters are left in for backwards compatability with edx-enterprise.
Creates an enterprise catalog.
Deletes an enterprise catalog.
Checks whether an enterprise customer has any catalogs that contain the provided content ids.
The endpoint does not differentiate between course_run_ids and program_uuids so they can be used interchangeably. The two query parameters are left in for backwards compatability with edx-enterprise.
Gets the representational difference between a list of course keys and the current state of content under an enterprise catalog. This difference is returned as three buckets of data: items_not_found, items_not_included and items_found.
enterprise_customer_catalog (EnterpriseCustomerCatalog) – The catalog object whose content is being diffed.
content_keys (list) – List of string content keys
should_raise_exception (Bool) – Optional param for whether or not api response exceptions should be raised.
dictionaries of content_keys to create items_to_delete (list): dictionaries of content_keys to delete items_found (list): dictionaries of content_keys and date_updated datetimes of content to update
items_to_create (list)
Return all content metadata contained in the catalogs associated with the EnterpriseCustomer.
enterprise_customer (EnterpriseCustomer) – The EnterpriseCustomer to return content metadata for.
enterprise_catalogs (EnterpriseCustomerCatalog) – Optional list of EnterpriseCustomerCatalog objects.
content_keys_filter (List) – List of content keys to filter by in the content metadata endpoint
List of dicts containing content metadata.
Get the url for the preview information for an enterprise catalog
Gets an enterprise catalog.
Kicks off async tasks to refresh catalogs so recent changes will populate to production without needing to wait for the daily jobs to run
enterprise_catalogs (EnterpriseCustomerCatalog) – List of EnterpriseCustomerCatalog objects to refresh
Dict of async task ids for each catalog id
Dict
Helper method to traverse over a paginated response from the enterprise-catalog service’s get_content_metadata endpoint.
Updates an enterprise catalog.
Bases: enterprise.api_client.client.NoAuthAPIClient
The enterprise catalog API client to make calls to the discovery service.
Utilities to get details from the course catalog API.
Bases: enterprise.api_client.client.UserAPIClient
The API client to make calls to the LMS Certificates API.
Note that this API client requires a JWT token, and so it keeps its token alive.
Retrieve the certificate for the given username for the given course_id.
Args:
* course_id
(str): The string value of the course’s unique identifier
* username
(str): The username ID identifying the user for which to retrieve the certificate
Returns:
a dict containing:
username
: A string representation of an user’s username passed in the request.
course_id
: A string representation of a Course ID.
certificate_type
: A string representation of the certificate type.
created_date
: Datetime the certificate was created (tz-aware).
status
: A string representation of the certificate status.
is_passing
: True if the certificate has a passing status, False if not.
download_url
: A string representation of the certificate url.
grade
: A string representation of a float for the user’s course grade.
Bases: enterprise.api_client.client.NoAuthAPIClient
The API client to make calls to the Course API.
Bases: object
Client interface for using the edx-platform embargo API.
Return redirect to embargo error page if the given user is blocked.
Bases: enterprise.api_client.client.BackendServiceAPIClient
The API client to make calls to the Enrollment API.
Call the enrollment API to enroll the user in the course specified by course_id.
username (str) – The username by which the user goes on the OpenEdX platform
course_id (str) – The string value of the course’s unique identifier
mode (str) – The enrollment mode which should be used for the enrollment
cohort (str) – Add the user to this named cohort
enterprise_uuid (str) – Add course enterprise uuid
A dictionary containing details of the enrollment, including course details, mode, username, etc.
Query the Enrollment API for the course details of the given course_id.
Query the enrollment API to get information about a single course enrollment.
Query the Enrollment API for the specific course modes that are available for the given course_id.
Query the enrollment API to get a list of the courses a user is enrolled in.
Query the Enrollment API to see whether a course run has a given course mode available.
Query the enrollment API and determine if a learner is enrolled in a course run.
Call the enrollment API to unenroll the user in the course specified by course_id. :param username: The username by which the user goes on the OpenEdx platform :type username: str :param course_id: The string value of the course’s unique identifier :type course_id: str
Whether the unenrollment succeeded
Call the enrollment API to update a user’s course enrollment to the specified mode, e.g. “audit”.
A dictionary containing details of the enrollment, including course details, mode, username, etc.
Bases: enterprise.api_client.client.UserAPIClient
The API client to make calls to the LMS Grades API.
Note that this API client requires a JWT token, and so it keeps its token alive.
Retrieve the assessment grades for the given username for the given course_id.
Args:
* course_id
(str): The string value of the course’s unique identifier
* username
(str): The username ID identifying the user for which to retrieve the grade.
Raises:
HTTPError if no grade found for the given user+course.
Returns:
a list of dicts containing:
attempted
: A boolean representing whether the learner has attempted the subsection yet.
subsection_name
: String representation of the subsection’s name.
category
: String representation of the subsection’s category.
label
: String representation of the subsection’s label.
score_possible
: The total amount of points that the learner could have earned on the subsection.
score_earned
: The total amount of points that the learner earned on the subsection.
percent
: A float representing the overall grade for the course.
module_id
: The ID of the subsection.
Retrieve the grade for the given username for the given course_id.
Args:
* course_id
(str): The string value of the course’s unique identifier
* username
(str): The username ID identifying the user for which to retrieve the grade.
Raises:
HTTPError if no grade found for the given user+course.
Returns:
a dict containing:
username
: A string representation of a user’s username passed in the request.
course_key
: A string representation of a Course ID.
passed
: Boolean representing whether the course has been passed according the course’s grading policy.
percent
: A float representing the overall grade for the course
letter_grade
: A letter grade as defined in grading_policy (e.g. ‘A’ ‘B’ ‘C’ for 6.002x) or None
Bases: enterprise.api_client.client.NoAuthAPIClient
The LMS API client to make calls to the LMS without authentication.
Bases: enterprise.api_client.client.UserAPIClient
The API client to make calls to the Third Party Auth API.
Retrieve the remote identifier for the given username.
Args:
* identity_provider
(str): identifier slug for the third-party authentication service used during SSO.
* username
(str): The username ID identifying the user for which to retrieve the remote name.
the remote name of the given user. None if not found.
string or None
Retrieve the remote identifier for the given username.
Args:
* identity_provider
(str): identifier slug for the third-party authentication service used during SSO.
* remote_id
(str): The remote id identifying the user for which to retrieve the usernamename.
the username of the given user. None if not found.
string or None