Repository navigation
Implemented Energy Optimization Unit management from CLI and Rest API - #61
Merged
Merged
Conversation
…e tracker IDs, they will be released in the nex release
…_details function
…s in ConfigurationService
…_policy_details function
…mproved filtering
…h improved selection options for energy sources, miners, policy and notifiers
…nfigurationService
…n units for better user experience
…mization unit management
…y monitor retrieval
This was referenced Apr 20, 2026
markoceri
marked this pull request as ready for review
November 23, 2025 22:46
GitGab19
approved these changes
Dec 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch implements the work needed for issue #32, delivering both the command-line interface and the REST API required to create, inspect, update, enable/disable, and delete Energy Optimization Units. It also introduces the associated validation schemas and integrates the new router into the FastAPI bootstrap so the endpoints are exposed alongside the existing domain APIs.
CLI Interaction
optimization_unit_menu(configuration_service, logger)adds three options to the interactive console: create, list, and manage units.handle_add_optimization_unit) walks the operator through selecting energy sources, policies, miners (multi-select), and notifiers. It refuses to proceed if any required selection is missing and logs errors via the provided logger.manage_single_optimization_unit_menu) lets operators activate/deactivate, update metadata and relationships, and add/remove individual miners or notifiers, delegating to helper functions such asmanage_assign_energy_sourceandmanage_add_target_miner.list_optimization_units,print_optimization_unit_details) format the output with colorizedclickstyles for immediate readability.REST API Interaction
All routes are mounted under
/api/v1/optimization-unitsthanks to the bootstrap change inedge_mining.adapters.infrastructure.api.main_api.GET /optimization-unitsEnergyOptimizationUnitSchema).POST /optimization-unitsEnergyOptimizationUnitCreateSchema, validating UUIDs and trimming strings.GET /optimization-units/{unit_id}PUT /optimization-units/{unit_id}DELETE /optimization-units/{unit_id}POST /optimization-units/{unit_id}/enableConfigurationService.activate_optimization_unit.POST /optimization-units/{unit_id}/disablePOST /optimization-units/{unit_id}/energy-sourcePOST /optimization-units/{unit_id}/policyPOST /optimization-units/{unit_id}/miners/POST .../miners/single/DELETE .../miners/{miner_id}POST /optimization-units/{unit_id}/notifiers/POST .../notifiers/single/DELETE .../notifiers/{notifier_id}How To Interact
CLI
python -m edge_mining cli interactive).REST API
python -m edge_mining).http://localhost:8001/docs)Additional Notes
ConfigurationServiceInterface, ensuring consistent validation and side-effects regardless of the entry point.OptimizationServicemakes optimization runs resilient when an adapter or external service is misconfigured, surfacing issues via the shared logger and optional notifications.