Resource History API
This guide explains the Resource History API which provides version tracking for marketplace Resource objects using django-reversion.
Overview
The Resource History API enables auditing and debugging by maintaining a complete change history for marketplace resources. Every modification to tracked fields creates a timestamped snapshot that can be queried via the API.
Use cases:
- Audit trail for compliance requirements
- Debugging resource configuration issues
- Tracking plan changes and cost evolution
- Investigating state transitions
Architecture
graph TD
A[Resource Change] --> B[django-reversion]
B --> C[Version Record]
C --> D[PostgreSQL]
E[History API] --> D
E --> F[Paginated Response]
The system uses django-reversion to capture resource snapshots on every save operation. Each version stores:
- Serialized field data
- Timestamp of the change
- User who made the change (if authenticated)
- Revision comment describing the change
API Endpoints
List Version History
Returns paginated version history for a resource, ordered by most recent first.
1 | |
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
created_before |
ISO 8601 timestamp | Filter versions created before this time |
created_after |
ISO 8601 timestamp | Filter versions created after this time |
Example Request:
1 2 | |
Example Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
Get Resource State at Timestamp
Returns the resource state as it existed at a specific point in time.
1 | |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
timestamp |
ISO 8601 timestamp | Yes | Point in time to query |
Example Request:
1 2 | |
Example Response (200 OK):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Error Responses:
| Status | Condition |
|---|---|
| 400 | Missing or invalid timestamp parameter |
| 404 | No version exists before the specified timestamp |
Provider Resources
The same endpoints are available for provider resources:
1 2 | |
Response Format
The ResourceVersionSerializer returns these fields:
| Field | Type | Description |
|---|---|---|
id |
integer | Version record ID |
revision_date |
datetime | When the change was recorded |
revision_user |
object/null | User who made the change |
revision_comment |
string | Description of the change |
serialized_data |
object | Snapshot of resource fields |
The revision_user object contains:
| Field | Type | Description |
|---|---|---|
uuid |
UUID | User identifier |
username |
string | Login username |
full_name |
string | Display name |
Tracked Fields
The following resource fields are tracked in version history:
| Field | Description |
|---|---|
name |
Resource display name |
description |
Resource description |
slug |
URL-friendly identifier |
state |
Current state (Creating, OK, Erred, etc.) |
limits |
Resource quotas and limits |
attributes |
Offering-specific attributes |
options |
User-configurable options |
cost |
Current monthly cost |
end_date |
Scheduled termination date |
downscaled |
Whether resource is downscaled |
restrict_member_access |
Access restriction flag |
paused |
Whether resource is paused |
plan |
Associated pricing plan |
Permissions
Access to history endpoints is restricted to:
- Staff users - Global administrators
- Support users - Global support personnel
Regular users (owners, admins, managers) cannot access resource history.
Actions That Create History
The following operations create version history entries:
| Action | Revision Comment |
|---|---|
| Resource update | Resource updated |
set_slug |
Slug changed to |
set_downscaled |
Downscaled changed to |
set_paused |
Paused changed to |
set_restrict_member_access |
Restrict member access changed to |
Django Admin Interface
The ResourceAdmin class inherits from VersionAdmin, providing a "History" button
in the Django admin interface. Staff users can:
- View all versions of a resource
- Compare differences between versions
- See who made each change and when
- Revert to a previous version (if needed)
Access the admin history at:
1 | |
Filtering Examples
Get changes in a date range
1 2 3 | |
Get state before an incident
1 2 3 | |
Related Documentation
- Resource Actions - Custom resource actions
- Waldur Permissions - Permission system details