enterprise.api package

Submodules

enterprise.api.filters module

enterprise.api.pagination module

Pagination helpers for enterprise api.

enterprise.api.pagination.get_paginated_response(data, request)

Update pagination links in course catalog data and return DRF Response.

Parameters:
  • data (dict) – Dictionary containing catalog courses.
  • request (HttpRequest) – Current request object.
Returns:

DRF response object containing pagination links.

Return type:

(Response)

enterprise.api.permissions module

Permission classes for the Enterprise API.

class enterprise.api.permissions.IsServiceUserOrReadOnly

Bases: rest_framework.permissions.IsAuthenticated

This request is authenticated as a service user, or is a read-only request.

has_permission(request, view)

Enforce that the user is authenticated. If the request isn’t read-only (unsafe), then deny permission unless the user is a service user.

enterprise.api.throttles module

Throttle classes for enterprise API.

class enterprise.api.throttles.ServiceUserThrottle

Bases: rest_framework.throttling.UserRateThrottle

A throttle allowing the service user to override rate limiting.

allow_request(request, view)

Modify throttling for service users.

Updates throttling rate if the request is coming from the service user, and defaults to UserRateThrottle’s configured setting otherwise.

Updated throttling rate comes from DEFAULT_THROTTLE_RATES key in REST_FRAMEWORK setting. service user throttling is specified in DEFAULT_THROTTLE_RATES by service_user key

Example Setting:

``` REST_FRAMEWORK = {

... ‘DEFAULT_THROTTLE_RATES’: {

... ‘service_user’: ‘50/day’

}

update_throttle_scope()

Update throttle scope so that service user throttle rates are applied.

enterprise.api.urls module

enterprise.api.utils module

Utility functions for the Enterprise API.

enterprise.api.utils.get_service_usernames()

Return the set of service usernames that are given extended permissions in the API.

Module contents