Phase 2, Task 2.2.1: Users API Implementation (Sync)
This commit adds comprehensive user management capabilities to the
Wiki.js Python SDK with full CRUD operations.
User Data Models (wikijs/models/user.py):
-----------------------------------------
1. **User** - Complete user data model
- Profile information (name, email, location, job title)
- Authentication details (provider, verified, active status)
- Group memberships with UserGroup nested model
- Timestamps (created, updated, last login)
- Email validation with pydantic EmailStr
- Name validation (2-255 characters)
2. **UserCreate** - User creation model
- Required: email, name, password
- Optional: groups, profile fields, provider settings
- Validation: email format, password strength (min 6 chars)
- Welcome email configuration
- Password change enforcement
3. **UserUpdate** - User update model
- All fields optional for partial updates
- Email, name, password updates
- Profile field updates
- Group membership changes
- Status flags (active, verified)
4. **UserGroup** - Group membership model
- Group ID and name
- Used in User model for group associations
Users Endpoint (wikijs/endpoints/users.py):
-------------------------------------------
Complete CRUD Operations:
1. **list()** - List users with filtering
- Pagination (limit, offset)
- Search by name/email
- Ordering (name, email, createdAt, lastLoginAt)
- Client-side pagination fallback
2. **get(user_id)** - Get user by ID
- Fetch single user with full details
- Include group memberships
- Comprehensive error handling
3. **create(user_data)** - Create new user
- Accept UserCreate object or dict
- Full validation before API call
- Returns created User object
- Handles creation failures gracefully
4. **update(user_id, user_data)** - Update existing user
- Partial updates supported
- Only sends changed fields
- Returns updated User object
- Validates all updates
5. **delete(user_id)** - Delete user
- Permanent deletion
- Returns boolean success
- Clear error messages
6. **search(query)** - Search users
- Search by name or email
- Optional result limiting
- Uses list() with search filter
Helper Methods:
- _normalize_user_data() - API response normalization
- Handles field name mapping (camelCase → snake_case)
- Group data structure conversion
Integration:
------------
- Added UsersEndpoint to WikiJSClient
- Updated endpoints module exports
- Added user models to main package exports
- Installed email-validator dependency for EmailStr
GraphQL Queries:
----------------
- users.list - List/search users
- users.single - Get user by ID
- users.create - Create new user
- users.update - Update existing user
- users.delete - Delete user
All queries include proper error handling and response validation.
Code Quality:
-------------
✅ Compiles without errors
✅ Type hints on all methods
✅ Comprehensive docstrings
✅ Input validation
✅ Proper exception handling
✅ Follows existing code patterns
Next Steps:
-----------
- Implement AsyncUsersEndpoint (async version)
- Write comprehensive tests
- Add usage documentation
- Create examples
Phase 2, Task 2.2.1 Progress: ~50% Complete
Users API (sync): ✅ COMPLETE
Users API (async): ⏳ IN PROGRESS
This establishes the foundation for complete user management
in the Wiki.js Python SDK.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Updated mypy configuration to use Python 3.9+
- Added missing type annotations to all function parameters
- Fixed type compatibility issues in variable assignments
- Resolved unreachable code and return type warnings
- All mypy checks now pass successfully
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Updated GitHub Actions workflow to use correct flake8 configuration
- Fixed line length issues by using 88 characters as configured
- Removed unused imports and trailing whitespace
- Fixed f-string placeholders and unused variables
- All linting checks now pass with project configuration
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
✅ Task 1.1 - Project Foundation Setup:
- Repository structure with Python packaging (setup.py, pyproject.toml)
- Development dependencies and requirements
- Contributing guidelines and MIT license
- GitHub workflows for CI/CD (test.yml, release.yml)
- Issue and PR templates for community contributions
- Comprehensive project documentation
✅ Task 1.2 - Core Client Structure:
- wikijs package with proper module organization
- Core client class foundation in client.py
- Exception hierarchy for error handling
- Base model classes and page models
- Type checking support (py.typed)
- Utility modules and helper functions
📊 Progress: Phase 1 MVP Development now 40% complete
🎯 Next: Task 1.3 - Authentication System implementation
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>