API Integrations
kasl supports integration with external services for enhanced task management and reporting capabilities.
Overview
Section titled “Overview”API integrations provide:
- Task Discovery: Import tasks from external systems
- Report Submission: Send reports to organizational systems
- Credential Management: Secure storage and authentication
- Session Handling: Automatic session management and renewal
GitLab Integration
Section titled “GitLab Integration”Import commits and merge requests as completed tasks.
-
Generate Access Token:
- Go to GitLab → User Settings → Access Tokens
- Create token with scopes:
read_user,read_repository - Copy the generated token
-
Configure Integration:
Terminal window kasl init# Follow prompts to configure GitLab
Configuration
Section titled “Configuration”{ "gitlab": { "access_token": "glpat-XXXXXXXXXXXXXXXXXXXX", "api_url": "https://gitlab.com" }}Features
Section titled “Features”- Commit Import: Automatically import today’s commits as completed tasks
- User Activity: Track user activity across repositories
- Repository Filtering: Support for multiple repositories
- Commit Message Parsing: Extract meaningful task names from commit messages
# Find tasks from GitLabkasl task find
# This will show:# - Incomplete local tasks# - Today's GitLab commits# - Interactive selection interfaceAPI Endpoints Used
Section titled “API Endpoints Used”GET /api/v4/user- Get user informationGET /api/v4/events- Get user eventsGET /api/v4/projects/{id}/repository/commits/{sha}- Get commit details
Jira Integration
Section titled “Jira Integration”Import completed issues and track work items.
-
Get Credentials:
- Username (not email, unless configured)
- Password (prompted interactively)
- Jira instance URL
-
Configure Integration:
Terminal window kasl init# Follow prompts to configure Jira
Configuration
Section titled “Configuration”{ "jira": { "login": "john.doe", "api_url": "https://company.atlassian.net" }}Features
Section titled “Features”- Issue Import: Import completed issues as tasks
- Status Tracking: Filter by issue status
- Project Support: Support for multiple projects
- Field Mapping: Custom field support
# Find tasks from Jirakasl task find
# This will show:# - Incomplete local tasks# - Today's GitLab commits# - Today's completed Jira issues# - Interactive selection interfaceAPI Endpoints Used
Section titled “API Endpoints Used”POST /rest/auth/1/session- AuthenticateGET /rest/api/2/search- Search issuesGET /rest/api/2/issue/{key}- Get issue details
SiServer Integration
Section titled “SiServer Integration”Submit reports to internal company systems.
-
Get Credentials:
- Corporate username
- Password (prompted interactively)
- Authentication URL
- API URL
-
Configure Integration:
Terminal window kasl init# Follow prompts to configure SiServer
Configuration
Section titled “Configuration”{ "si": { "login": "john.doe@company.com", "auth_url": "https://auth.company.com", "api_url": "https://api.company.com" }}Features
Section titled “Features”- Daily Reports: Submit daily work reports
- Monthly Reports: Submit monthly summaries
- Rest Dates: Import company holidays and rest days
- Secure Authentication: LDAP-based authentication
# Submit daily reportkasl report --send
# Submit monthly reportkasl sum --send
# This will:# - Authenticate with SiServer# - Format report data# - Submit via API# - Handle errors and retriesAPI Endpoints Used
Section titled “API Endpoints Used”POST /auth/login- AuthenticatePOST /reports/daily- Submit daily reportPOST /reports/monthly- Submit monthly reportGET /calendar/rest-dates- Get rest dates
Credential Management
Section titled “Credential Management”Secure Storage
Section titled “Secure Storage”Credentials are stored securely:
- API Tokens: Encrypted in separate files
- Passwords: Not stored, prompted interactively
- Session Data: Cached temporarily
File Locations
Section titled “File Locations”- Windows:
%LOCALAPPDATA%\lacodda\kasl\ - macOS:
~/Library/Application Support/lacodda/kasl/ - Linux:
~/.local/share/lacodda/kasl/
Encryption
Section titled “Encryption”- Algorithm: AES-256-CBC
- Key Management: Compile-time embedded keys
- File Permissions: Restricted access
Session Management
Section titled “Session Management”Automatic Handling
Section titled “Automatic Handling”Sessions are managed automatically:
- Authentication: Prompted when needed
- Caching: Sessions cached for performance
- Renewal: Automatic session renewal
- Cleanup: Expired sessions removed
Session Files
Section titled “Session Files”.gitlab_session- GitLab session data.jira_session- Jira session data.si_session- SiServer session data
Error Handling
Section titled “Error Handling”- Network Errors: Automatic retry with backoff
- Authentication Failures: Re-prompt for credentials
- Session Expiry: Automatic re-authentication
- Rate Limiting: Respect API rate limits
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Problem: Authentication failures
# Clear cached sessionsrm ~/.local/share/lacodda/kasl/.gitlab_sessionrm ~/.local/share/lacodda/kasl/.jira_sessionrm ~/.local/share/lacodda/kasl/.si_session
# Reconfigure integrationkasl initProblem: API connection errors
# Test connectivitycurl -H "Authorization: Bearer YOUR_TOKEN" https://gitlab.com/api/v4/user
# Check network settingsping gitlab.comProblem: Rate limiting
# Wait and retry# kasl handles rate limiting automatically# Check API documentation for limitsDebug Mode
Section titled “Debug Mode”Enable debug logging for API operations:
RUST_LOG=kasl=debug kasl task findThis will show:
- API requests and responses
- Authentication attempts
- Session management
- Error details
API Limits
Section titled “API Limits”Be aware of API rate limits:
- GitLab: 600 requests/hour for authenticated users
- Jira: Varies by plan and usage
- SiServer: Depends on company configuration
Best Practices
Section titled “Best Practices”Security
Section titled “Security”- Token Rotation: Regularly rotate API tokens
- Minimal Permissions: Use tokens with minimal required scopes
- Secure Storage: Keep configuration files secure
- Network Security: Use HTTPS for all API communications
Performance
Section titled “Performance”- Caching: Sessions are cached to reduce API calls
- Batch Operations: Use batch operations when possible
- Rate Limiting: Respect API rate limits
- Connection Pooling: Efficient HTTP connection management
Monitoring
Section titled “Monitoring”- Error Tracking: Monitor for authentication failures
- Usage Monitoring: Track API usage patterns
- Performance Metrics: Monitor response times
- Log Analysis: Review debug logs for issues
Custom Integrations
Section titled “Custom Integrations”Adding New APIs
Section titled “Adding New APIs”To add support for new APIs:
- Create API Client: Implement the
Sessiontrait - Add Configuration: Extend configuration structure
- Update Commands: Add integration to relevant commands
- Add Tests: Comprehensive test coverage
Example Implementation
Section titled “Example Implementation”pub struct CustomApi { client: Client, config: CustomConfig, credentials: Option<LoginCredentials>, retries: i32,}
impl Session for CustomApi { async fn login(&self) -> Result<String> { // Implementation }
fn set_credentials(&mut self, password: &str) -> Result<()> { // Implementation }
// ... other required methods}Configuration Extension
Section titled “Configuration Extension”{ "custom_api": { "login": "username", "api_url": "https://api.example.com" }}