Registration
registration
Service class for handling registration workflows in Kaleidoscope.
This module provides methods for driving the registration lifecycle of operation files, including creating registrations, listing registration files for an operation, pushing intermediate status updates (e.g. after external validation), and submitting final results.
The typical webhook-driven workflow is:
- Receive a
registration_submittedwebhook event containing afile_urlandrecord_ids. - Download the file using :meth:
FilesService.download_file. - Process the file externally.
- (Optional) Push intermediate status via
:meth:
RegistrationService.push_status(e.g.validated,validation_failed). - Submit final results via :meth:
RegistrationService.submit_results.
Classes:
| Name | Description |
|---|---|
RegistrationFileStatusEnum |
Lifecycle states for a registration file. |
RegistrationResultStatusEnum |
Terminal statuses for a results submission. |
RegistrationResultError |
Per-record error from a failed registration. |
RegistrationFile |
A registration attempt for a file within an operation. |
RegistrationFileWithErrors |
A registration file with any per-record errors attached. |
RegistrationService |
Service for the registration endpoints. |
RegistrationFileStatusEnum
Lifecycle states for a registration file.
Attributes:
| Name | Type | Description |
|---|---|---|
PENDING |
Registration created, awaiting processing. |
|
VALIDATED |
External validation succeeded. |
|
VALIDATION_FAILED |
External validation failed. |
|
SUBMITTED |
Results have been submitted for processing. |
|
COMPLETED |
Registration completed successfully. |
|
FAILED |
Registration failed. |
RegistrationResultStatusEnum
RegistrationResultError
RegistrationFile
Bases: _KaleidoscopeBaseModel
A registration attempt for a file within an operation.
Attributes:
| Name | Type | Description |
|---|---|---|
workspace_id |
str
|
ID of the workspace. |
operation_id |
str
|
ID of the operation this registration belongs to. |
file_id |
str
|
ID of the file being registered. |
status |
RegistrationFileStatusEnum
|
Current lifecycle state. |
message |
str | None
|
Status message set by the processor. |
created_by |
str
|
ID of the user who created the registration. |
last_updated_by |
str
|
ID of the user who last updated the registration. |
created_at |
str
|
ISO timestamp when the registration was created. |
updated_at |
str
|
ISO timestamp when the registration was last updated. |
RegistrationFileWithErrors
Bases: RegistrationFile
A registration file with any per-record errors attached.
Attributes:
| Name | Type | Description |
|---|---|---|
record_errors |
list[RegistrationResultError]
|
Errors for records
that failed to register. Empty unless |
RegistrationService
RegistrationService(client: KaleidoscopeClient)
Service class for registration workflows.
Provides methods to create registrations, list registration files for an operation, push intermediate status updates, and submit final results.
Methods:
| Name | Description |
|---|---|
register_file |
Register a file with an operation. |
get_registration_files |
List all registration files for an operation. |
push_status |
Push the current status of a registration file. |
submit_results |
Submit registration results for a processed file. |
Source code in kalbio/registration.py
146 147 | |
register_file
register_file(operation_id: str, file_id: str) -> RegistrationFile
Register a file with an operation.
Creates a registration for a previously uploaded file, submitting it for external registration processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_id
|
str
|
The operation to register the file with. |
required |
file_id
|
str
|
The uploaded file to register. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RegistrationFile |
RegistrationFile
|
The newly created registration. |
Raises:
| Type | Description |
|---|---|
KalbioAPIError
|
If the API request fails. |
Source code in kalbio/registration.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
get_registration_files
get_registration_files(operation_id: str) -> list[RegistrationFileWithErrors]
List all registration files for an operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_id
|
str
|
The operation to list registrations for. |
required |
Returns:
| Type | Description |
|---|---|
list[RegistrationFileWithErrors]
|
List[RegistrationFileWithErrors]: Registration files for the |
list[RegistrationFileWithErrors]
|
operation. |
list[RegistrationFileWithErrors]
|
whose |
Raises:
| Type | Description |
|---|---|
KalbioAPIError
|
If the API request fails. |
Source code in kalbio/registration.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
push_status
push_status(operation_id: str, file_id: str, status: RegistrationFileStatusEnum, message: str | None = None) -> bool
Push the current status of a registration file.
Used to report intermediate lifecycle updates from an external
processor (e.g. validated, validation_failed) without
submitting full results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_id
|
str
|
The operation the registration belongs to. |
required |
file_id
|
str
|
The registration file to update. |
required |
status
|
RegistrationFileStatusEnum
|
The status to push. |
required |
message
|
str
|
Optional message to attach to the status update. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the request succeeded (204). |
Raises:
| Type | Description |
|---|---|
KalbioAPIError
|
If the API request fails. |
Source code in kalbio/registration.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
submit_results
submit_results(operation_id: str, file_id: str, status: RegistrationResultStatusEnum, message: str | None = None, key_field_names: list[str] | None = None, records: list[dict[str, Any]] | None = None) -> bool
Submit registration results for a processed file.
Called after downloading and processing a file from a
registration_submitted webhook event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_id
|
str
|
The operation ID from the webhook event. |
required |
file_id
|
str
|
The file ID from the webhook event. |
required |
status
|
RegistrationResultStatusEnum
|
Overall result status. |
required |
message
|
str
|
Message to attach to the results. |
None
|
key_field_names
|
list[str]
|
Names of key fields in the
result data (e.g. |
None
|
records
|
list[dict[str, Any]]
|
Per-record results. Each
dict should contain |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the results were submitted successfully (204). |
Raises:
| Type | Description |
|---|---|
KalbioAPIError
|
If the API request fails. |
Source code in kalbio/registration.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |