-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add BuildCommand support and missing fields to API v3 Build endpoint #12562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add BuildCommandSerializer for build command results - Add commands field to BuildSerializer - Add docs_url field to BuildSerializer - Add commit_url field to BuildSerializer - Add builder field to BuildSerializer - Enable ?expand=notifications for Build endpoint - Add comprehensive tests for new fields and expand functionality - Update test fixtures to include new fields Co-authored-by: ericholscher <[email protected]>
Co-authored-by: ericholscher <[email protected]>
|
@copilot Update the public REST API docs, not the design docs. |
- Revert changes to docs/dev/design/apiv3.rst (design docs) - Add new Build endpoint fields to docs/user/api/v3.rst (public API docs) - Document commands, commit_url, docs_url, builder fields - Update expand parameter to include notifications option Co-authored-by: ericholscher <[email protected]>
Updated the public REST API docs (
Commit: 3021e5a |
|
@copilot Use a similar cold_storage approach for build commands from API v2, and abstract it into a common util. |
- Created get_commands_from_cold_storage() utility in api/v2/utils.py - Refactored API v2 BuildViewSet.retrieve() to use the common utility - Added retrieve() method to API v3 BuildsViewSet using the same utility - This ensures both APIs handle cold storage builds consistently Co-authored-by: ericholscher <[email protected]>
Implemented the cold storage approach similar to API v2 and abstracted it into a common utility:
Both API v2 and v3 now share the same cold storage logic, ensuring consistent behavior for builds that have been moved to cold storage. Commit: 7e20afe |
Summary: Add missing fields to API v3 Build endpoint ✅
All requirements from the issue have been successfully implemented:
commandsfield to BuildSerializer (BuildCommand support)docs_urlfield to BuildSerializercommit_urlfield to BuildSerializerbuilderfield to BuildSerializer (for debugging)?expand=configfor the config object (verified existing functionality)?expand=notificationsfor notifications expansionImplementation Details
1. Serializers (
readthedocs/api/v3/serializers.py)Added BuildCommandSerializer:
Enhanced BuildSerializer with new fields:
commands: List of BuildCommandResult objects (many=True)docs_url: URL to built documentation viaget_docs_url()methodcommit_url: URL to VCS commit via model'sget_commit_url()builder: Builder hostname for debugging purposesnotificationsto expandable_fields for?expand=notificationssupport2. Views (
readthedocs/api/v3/views.py)BuildsViewSet.permit_list_expandsto include"notifications"alongside existing"config"retrieve()method to handle cold storage builds, loading commands from S3 when available3. Common Utility (
readthedocs/api/v2/utils.py)Created
get_commands_from_cold_storage()function:4. API v2 Refactoring (
readthedocs/api/v2/views/model_views.py)BuildViewSet.retrieve()to use the new common utility5. Tests (
readthedocs/api/v3/tests/)Test fixtures updated:
New test coverage:
test_projects_builds_detail_has_new_fields(): Validates presence and values of new fieldstest_projects_builds_detail_expand_config(): Tests config expansiontest_projects_builds_detail_expand_notifications(): Tests notification expansion6. Documentation (
docs/user/api/v3.rst)Updated public REST API documentation with:
Code Quality
✅ All Python files pass syntax validation
✅ All JSON fixtures are valid
✅ Implementation follows existing v2 API patterns
✅ Consistent error handling (returns None for missing version)
✅ No trailing whitespace or obvious style issues
✅ Comprehensive docstrings added
✅ Cold storage logic abstracted into reusable utility function
✅ Both API v2 and v3 use the same cold storage approach
API Usage Examples
Get build with new fields:
Expand config:
Expand notifications:
Expand both:
This implementation addresses all requirements from the issue and brings the v3 Build API to feature parity with v2 while supporting the new dashboard needs. The cold storage logic is now abstracted into a common utility function used by both API versions.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.