src.dackar.RCA.cap_integration.cap_adapter¶
cap_adapter — CAPAdapter Protocol, FileDropCAPAdapter, NoOpCAPAdapter.
Concrete live adapters (MaximoCAPAdapter, SAPPMCAPAdapter) live in separate files and implement the same Protocol. See CAP_INTEGRATION_GUIDE.md for the implementation skeleton.
Attributes¶
Classes¶
Returned by every CAPAdapter.submit() call. |
|
Protocol for CAP submission adapters. |
|
Writes the CAPExportPackage as a JSON file to a watched directory. |
|
Silently discards the package. Used in unit tests and CI. |
Functions¶
|
Return a filesystem-safe stem for CAP export files. |
Module Contents¶
- src.dackar.RCA.cap_integration.cap_adapter._safe_export_filename(export_id)[source]¶
Return a filesystem-safe stem for CAP export files.
- Parameters:
export_id (str)
- Return type:
str
- class src.dackar.RCA.cap_integration.cap_adapter.CAPSubmissionReceipt[source]¶
Returned by every CAPAdapter.submit() call.
- cr_numbers[source]¶
CMMS-assigned corrective action / work order numbers. Empty list for adapters that do not receive synchronous confirmation (e.g.
FileDropCAPAdapter).
- class src.dackar.RCA.cap_integration.cap_adapter.CAPAdapter[source]¶
Bases:
ProtocolProtocol for CAP submission adapters.
All implementations must be idempotent with respect to
package["export_id"]: submitting the same package twice must not create duplicate CMMS records.
- class src.dackar.RCA.cap_integration.cap_adapter.FileDropCAPAdapter(drop_dir)[source]¶
Writes the CAPExportPackage as a JSON file to a watched directory.
This is the default adapter for dev and pre-live deployments. The plant’s CMMS import job polls the directory and ingests the file asynchronously. Returns a receipt with
status="pending"and an emptycr_numberslist — CMMS record numbers are not available at submission time.- Parameters:
drop_dir (str | pathlib.Path) – Directory where export files are written. Created if absent.
- submit(package)[source]¶
Write the package to the drop zone as JSON and return a receipt.
The file is written atomically (to a hidden
*.tmpsibling, thenos.replace``d into place) so a CMMS import job polling the directory never observes a partially written ``cap_export_*.jsonfile.- Parameters:
package (JsonDict) – Dict conforming to
schemas/cap_export_package.json.- Returns:
status="pending"with an emptycr_numberslist;notesholds the written file path.- Return type:
- class src.dackar.RCA.cap_integration.cap_adapter.NoOpCAPAdapter[source]¶
Silently discards the package. Used in unit tests and CI.
Returns a receipt with
status="noop"and an emptycr_numberslist. Makes no file I/O and has no external dependencies.