-
Notifications
You must be signed in to change notification settings - Fork 8
Implemented Energy Optimization Unit management from CLI and Rest API #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
markoceri
wants to merge
19
commits into
dev
Choose a base branch
from
energy-optimization-unit_cli-and-rest-api
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
…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 Nov 23, 2025
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.