Implement Lobster PIM Legacy REST API client with authentication, job control, and protocol access

- Added `rest_api` module with client and authentication classes.
- Implemented `LobsterRestApiClient` for interacting with the REST API.
- Created models for job and protocol responses using Pydantic.
- Developed examples demonstrating basic usage, API token authentication, job execution, and error handling.
- Added unit tests for authentication and client methods, including error handling scenarios.
This commit is contained in:
claudi 2026-02-20 10:35:34 +01:00
parent 1324be4084
commit 8d4fcc7d11
9 changed files with 1766 additions and 0 deletions

View file

@ -109,6 +109,62 @@ config = ElytraConfig.from_env()
client = ElytraClient(base_url=config.base_url, api_key=config.api_key)
```
## Legacy REST API (Lobster PIM)
The package also includes a subpackage for the older Lobster PIM REST API, which provides access to scheduled jobs and protocol logs that are not yet available in the newer API.
### Quick Start
```python
from elytra_client.rest_api import LobsterRestApiClient, RestApiAuth
# Create authentication
auth = RestApiAuth.from_username_password("username", "password")
# Create client for the REST API
client = LobsterRestApiClient("http://lobster-server:8080", auth=auth)
# Get all active jobs
jobs = client.get_all_active_jobs()
for job in jobs.jobInfoObjects:
print(f"Job: {job.name} - Status: {job.status}")
# Execute a job
result = client.execute_job(job_id=123)
print(f"Execution started with runtime ID: {result.runtimeId}")
# Get protocol/logs
protocols = client.get_protocols()
```
### Features
- 📋 **Job Management**: Access, monitor, and execute scheduled jobs
- 📜 **Protocol/Logs**: Retrieve execution logs and protocol information
- 🔐 **Flexible Authentication**: Username/password or API token authentication
- ⏳ **Job Control**: Execute jobs with parameter overrides and queue management
- 🎯 **Type Safety**: Full Pydantic validation for all responses
### Authentication Methods
```python
# Username/Password
auth = RestApiAuth.from_username_password("admin", "password")
# API Token (domain-specific)
auth = RestApiAuth.from_api_token("admin", "token-id", domain="Jobs")
```
### Documentation
See [elytra_client/rest_api/README.md](elytra_client/rest_api/README.md) for comprehensive REST API documentation, including:
- Complete API reference
- Authentication details
- Job management examples
- Protocol/log access
- Error handling
- Common usage scenarios
## API Methods
All methods return Pydantic models with full type validation and IDE autocompletion support.