Django Views#
The REST API is implemented with Django REST Framework class-based views in
cdb_rest/views.py. For endpoint URLs, parameters, and example requests, see
API Documentation; this page is the code-level reference.
View Categories#
- Global Tag views
List, retrieve (by ID or name), create, clone, delete, and change the status of Global Tags. Deletion and status changes enforce the
locked/frozenimmutability rules.- Payload Type views
List, create, and delete payload types. Deletion is refused while any PayloadList still references the type.
- Payload List views
List and create payload lists (names are auto-generated from the payload type and a sequence ID), attach lists to Global Tags, and delete empty lists.
- Payload IOV views
Create payload IOVs (single or bulk), attach them to payload lists with overlap resolution, delete them, and query them. IOV validation and overlap handling delegate to the mode strategies in
cdb_rest/iov_comparisons.py(CDB_IOV_MODE).- Query views
PayloadIOVsSQLListAPIViewbacks the main/payloadiovs/endpoint. It executes a raw SQL query fromcdb_rest/queries.py(selected by theCDB_PAYLOAD_IOVS_QUERYsetting) and distributes reads across the configuredread_db_*replicas.- Settings view
CDBSettingAPIViewexposesCDB_*environment variables read-only.
Authentication and Permissions#
All views mix in WriteAuthMixin: when CDB_AUTH_CLASS is set, write methods
(POST/PUT/PATCH/DELETE) authenticate with the configured class while reads stay anonymous.
Write views additionally call the permission plugin loaded from
CDB_PERMISSION_PLUGIN_CLASS (see cdb_rest/permissions_plugins/) before modifying
data.
View Reference#
The following documentation is generated from the view classes and their docstrings.
- class cdb_rest.views.WriteAuthMixin[source]#
Bases:
objectRequire JWT authentication for write methods (POST/PUT/PATCH/DELETE), allow anonymous reads.
- cdb_rest.views.paginate_browse(request, queryset, serializer_class, search_fields, sort_map, default_sort)[source]#
Server-side search/sort/pagination for browse endpoints (opt-in via ?page=).
Returns {count, page, page_size, total_pages, results}. Sort fields are whitelisted through sort_map to prevent ordering by arbitrary columns.
- class cdb_rest.views.GlobalTagDetailAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,RetrieveAPIView- serializer_class#
alias of
GlobalTagReadSerializer
- queryset = QuerySet#
- class cdb_rest.views.GlobalTagByNameDetailAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,RetrieveAPIViewRetrieve a GlobalTag by name with all nested PayloadLists and IOVs.
Pass ?light=1 to get metadata only (no nested payload lists), with payload list / IOV counts computed in the database.
- serializer_class#
alias of
GlobalTagReadSerializer
- queryset = QuerySet#
- lookup_url_kwarg = 'globalTagName'#
- class cdb_rest.views.TimeoutListAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListAPIViewTest endpoint that simulates a long-running request (30 min timeout).
- class cdb_rest.views.GlobalTagListCreationAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListCreateAPIViewList all GlobalTags (GET) or create a new one (POST). Requires admin permission to create.
- serializer_class#
alias of
GlobalTagCreateSerializer
- get_queryset()[source]#
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)
- class cdb_rest.views.GlobalTagDeleteAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,DestroyAPIViewDelete a GlobalTag by name. Locked and frozen GTs are immutable.
- serializer_class#
alias of
GlobalTagReadSerializer
- lookup_url_kwarg = 'globalTagName'#
- lookup_field = 'name'#
- class cdb_rest.views.PayloadIOVDeleteAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,DestroyAPIViewDelete a PayloadIOV. Frozen GTs are immutable.
- serializer_class#
alias of
PayloadIOVSerializer
- class cdb_rest.views.PayloadTypeDeleteAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,DestroyAPIViewDelete a PayloadType. Fails if any PayloadLists reference it.
- serializer_class#
alias of
PayloadTypeSerializer
- class cdb_rest.views.PayloadListDeleteAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,DestroyAPIViewDelete a PayloadList. Fails if it contains any PayloadIOVs.
- serializer_class#
alias of
PayloadListSerializer
- class cdb_rest.views.GlobalTagsListAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListAPIViewList all GlobalTags with attached PayloadLists summary.
Pass ?page= to get a paginated response with server-side search (?search=), status filter (?status=) and sorting (?sort=&order=).
- serializer_class#
alias of
GlobalTagListSerializer
- get_queryset()[source]#
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)
- class cdb_rest.views.GlobalTagsDetailedListAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListAPIViewList all GlobalTags with status name and per-tag payload counts.
- serializer_class#
alias of
GlobalTagDetailedSerializer
- get_queryset()[source]#
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)
- class cdb_rest.views.GlobalTagsPayloadListsListAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListAPIViewList PayloadLists for a given GlobalTag as a {payload_type: name} map.
- get_queryset()[source]#
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)
- class cdb_rest.views.GlobalTagStatusCreationAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListCreateAPIViewList or create GlobalTag statuses (unlocked, locked, frozen).
- serializer_class#
alias of
GlobalTagStatusSerializer
- lookup_field = 'name'#
- get_queryset()[source]#
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)
- class cdb_rest.views.PayloadListListCreationAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListCreateAPIViewList all PayloadLists (GET) or create a new one (POST). Auto-generates name from PayloadType + sequence ID.
Pass ?page= to get a paginated response without nested IOVs, with server-side search (?search=), filters (?global_tag=, ?payload_type=) and sorting (?sort=&order=).
- serializer_class#
alias of
PayloadListCreateSerializer
- get_queryset()[source]#
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)
- class cdb_rest.views.PayloadListDetailAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,RetrieveAPIView- serializer_class#
alias of
PayloadListCreateSerializer
- queryset = QuerySet#
- class cdb_rest.views.PayloadListByNameAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,RetrieveAPIViewRetrieve a PayloadList by name (metadata + IOV count, no nested IOVs).
- serializer_class#
alias of
PayloadListBrowseSerializer
- class cdb_rest.views.PayloadTypeListCreationAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListCreateAPIViewList all PayloadTypes (GET) or create a new one (POST).
Pass ?page= to get a paginated response with server-side search (?search=) and sorting (?sort=&order=).
- serializer_class#
alias of
PayloadTypeSerializer
- get_queryset()[source]#
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)
- class cdb_rest.views.PayloadIOVListCreationAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListCreateAPIViewList all PayloadIOVs (GET) or create a new one (POST). Validates IOV ranges based on CDB_IOV_MODE.
Pass ?page= to get a paginated response of flat rows including payload list / global tag / payload type names, with server-side search (?search=), filters (?payload_list=, ?global_tag=, ?payload_type=) and sorting (?sort=&order=).
- serializer_class#
alias of
PayloadIOVSerializer
- get_queryset()[source]#
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)
- class cdb_rest.views.PayloadIOVDetailAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,RetrieveAPIView- serializer_class#
alias of
PayloadIOVSerializer
- queryset = QuerySet#
- class cdb_rest.views.PayloadIOVBulkCreationAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,CreateAPIViewBulk-create PayloadIOVs from a JSON array. Skips individual validation for performance.
- serializer_class#
alias of
PayloadIOVSerializer
- get_queryset()[source]#
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)
- class cdb_rest.views.GlobalTagCloneAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,CreateAPIViewDeep-copy a GlobalTag: duplicates the GT, all its PayloadLists, and their PayloadIOVs.
- serializer_class#
alias of
GlobalTagReadSerializer
- class cdb_rest.views.PayloadIOVsORMMaxListAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListAPIViewGet latest PayloadIOVs per PayloadList for a given GT and IOV point, using ORM MAX aggregation.
- get_queryset()[source]#
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)
- class cdb_rest.views.PayloadIOVsORMOrderByListAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListAPIViewGet latest PayloadIOVs per PayloadList using ORM ORDER BY + DISTINCT.
- get_queryset()[source]#
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)
- class cdb_rest.views.PayloadIOVsSQLListAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListAPIViewGet PayloadIOVs using raw SQL for performance. Distributes reads across read replicas.
- class cdb_rest.views.PayloadIOVsRangesListAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,ListAPIViewGet PayloadIOVs within a given IOV range, grouped by PayloadList.
- get_queryset()[source]#
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)
- class cdb_rest.views.PayloadListAttachAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,UpdateAPIViewAttach a PayloadList to a GlobalTag. Detaches any existing list of the same PayloadType first.
- serializer_class#
alias of
PayloadListCreateSerializer
- class cdb_rest.views.PayloadIOVAttachAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,UpdateAPIViewAttach a PayloadIOV to a PayloadList. Handles overlap resolution: - Locked GT: rejects conflicting IOVs (append-only), with special case for open-ended Online GT IOVs. - Unlocked GT: splits/trims existing IOVs to accommodate the new one.
- serializer_class#
alias of
PayloadIOVSerializer
- class cdb_rest.views.GlobalTagChangeStatusAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,UpdateAPIViewChange a GlobalTag’s status (e.g. unlocked -> locked -> frozen).
- serializer_class#
alias of
GlobalTagCreateSerializer
- class cdb_rest.views.CDBSettingAPIView(**kwargs)[source]#
Bases:
WriteAuthMixin,APIViewExpose CDB_* environment variables as read-only settings.
- class cdb_rest.views.AuthDecisionAPIView(**kwargs)[source]#
Bases:
APIViewAuthorization decision endpoint for nginx auth_request subrequests.
nginx passes the original request’s method and URI in the X-Original-Method and X-Original-URI headers. Reads are always allowed, file uploads (PUT) require authentication and the permission plugin’s approval, and any other method is denied. Returns 200 to allow, 401/403 to deny; no response body is needed.
See Also#
API Documentation - Complete API endpoint documentation
Database Models - Database models used by these views
Architecture - Overall system architecture and design