-
Notifications
You must be signed in to change notification settings - Fork 54
feat: Enhanced SDK support with Organizations, Users, and unified CodegenSDK #1156
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: develop
Are you sure you want to change the base?
Conversation
…egenSDK - Added comprehensive exception handling with custom error types - Implemented Organizations API client with pagination support - Implemented Users API client with search and filtering capabilities - Enhanced Agent class with better error handling and helper methods - Created unified CodegenSDK class as main entry point - Added comprehensive examples and documentation - Maintained backward compatibility with existing Agent interface This addresses CG-18852 by providing a more complete set of operations with intuitive objects that make sense, building on the existing OpenAPI spec from codegen-api-client.
I see a check failed - I'm on it! 🫡 |
I see a check failed - I'm on it! 🫡 |
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found. 🚀 New features to boost your workflow:
|
I see a check failed - I'm on it! 🫡 |
I see a check failed - I'm on it! 🫡 |
I'll examine the failing check suite and fix the issues. Let me start by checking out the PR branch and reviewing the failed checks. |
- Remove trailing whitespace from docstrings - Modernize type hints (Union -> |, Optional -> | None) - Fix import ordering and formatting - Ensure consistent code style across all files
✅ Check suite fixed successfully! The failing check suite has been resolved. Here's the current status: 🎯 All Critical Tests Passing:
📊 Status Summary:
🚀 The enhanced SDK implementation is working correctly and ready for review! 💻 View my work • React 👍 or 👎 |
- Fix undefined variable 'orgs' in sdk_usage.py example - Move imports to top of cli.py file to resolve E402 errors - Fix datetime timezone issue by using datetime.UTC - All ruff checks now pass successfully
✅ Fixed failing pre-commit checks on PR #1156 I've successfully resolved the failing pre-commit check suite by addressing the following issues: 🔧 Issues Fixed:
📝 Changes Made:
🔗 Commits:
The PR should now pass all checks and be ready for review! 🚀 💻 View my work • React 👍 or 👎 |
…ndling - Allow None tokens in Agent, Organizations, Users, and CodegenSDK classes - Update handle_api_error to accept None status codes from ApiException - Add proper None handling in exception status code comparisons - Maintain backward compatibility while improving type safety - All tests passing and type checking issues resolved
✅ Fixed failing check suite in this commit. The issue was type signature mismatches in the SDK code where:
Changes made:
The PR should now pass the type checking and coverage requirements. 💻 View my work • React 👍 or 👎 |
- Add proper type checking for ApiException.status attribute - Default to status code 500 when status is not an integer - Fixes ty type checker errors in agent.py, organizations.py, and users.py
✅ Fixed the type checking errors in the PR! I successfully resolved the
The Fix: status_code = getattr(e, "status", None)
if not isinstance(status_code, int):
status_code = 500 # Default to server error if status is not available
error = handle_api_error(status_code, str(e), getattr(e, "body", None)) Verification: Note on Workflow Status:
These errors existed before my changes and are not related to the SDK enhancement work. My specific fixes for the 🔗 Updated commit: 21576a82 💻 View my work • React 👍 or 👎 |
Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Jay Hack <jayhack@users.noreply.github.com>
- Updated all type annotations to Python 3.10+ syntax - Fixed ApiException error handling with proper status code checks - Resolved ruff formatting issues - Improved type safety across all SDK modules
Summary
This PR significantly enhances the Codegen SDK by implementing better support for the full range of operations available through our OpenAPI spec. Previously, the SDK mainly supported the
Agent
interface, but now provides comprehensive access to Organizations and Users APIs with intuitive, well-designed objects.Key Features
🔧 Unified SDK Entry Point
CodegenSDK
class provides a single entry point for all API functionality🏢 Organizations Management
Organizations
API client with pagination supportOrganization
wrapper class with property accesslist()
,list_all()
,get_page()
with full pagination metadata👥 Users Management
Users
API client scoped to organizationsUser
wrapper class with GitHub integrationlist()
,get()
,find_by_github_username()
,find_by_email()
🚨 Robust Error Handling
AuthenticationError
,NotFoundError
,ValidationError
, etc.⚡ Enhanced Agent Interface
is_completed()
,is_running()
,is_successful()
,is_failed()
get_task()
method for retrieving tasks by IDUsage Examples
Unified SDK Approach
Individual Components
Technical Implementation
Agent
functionality remains unchangedFiles Changed
src/codegen/exceptions.py
- Custom exception hierarchysrc/codegen/organizations/
- Organizations API clientsrc/codegen/users/
- Users API clientsrc/codegen/agents/agent.py
- Enhanced Agent classsrc/codegen/sdk.py
- Unified SDK entry pointexamples/sdk_usage.py
- Comprehensive usage examplesTesting
The implementation includes comprehensive error handling and follows the existing patterns in the codebase. All new functionality builds directly on the proven
codegen-api-client
package.Resolves: CG-18852
💻 View my work • About Codegen