Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fe1f5e6
cli: http: api: blueprint download: do not require `-o`
rnovatorov Mar 11, 2026
c888a5d
feat(http/api/rule_engine): Checkpoint end of Phase 1: Models and Fou…
rnovatorov Mar 11, 2026
d56f9c8
conductor(plan): Mark phase 'Phase 1: Models and Foundation' as complete
rnovatorov Mar 11, 2026
6745120
feat(http/api/rule_engine): Checkpoint end of Phase 2: Rule Managemen…
rnovatorov Mar 11, 2026
cd71ca5
conductor(plan): Mark phase 'Phase 2: Rule Management Implementation …
rnovatorov Mar 11, 2026
15e657c
feat(http/api/rule_engine): Checkpoint end of Phase 3: Rule Managemen…
rnovatorov Mar 17, 2026
dd7f2a2
conductor(plan): Mark phase 'Phase 3: Rule Management Implementation …
rnovatorov Mar 17, 2026
43df5d0
feat(http/api/rule_engine): Checkpoint end of Phase 4: Rule State Man…
rnovatorov Mar 17, 2026
1f01f88
conductor(plan): Mark phase 'Phase 4: Rule State Management' as complete
rnovatorov Mar 17, 2026
90987b4
feat(http/api/rule_engine): Add exec_interval to RuleScript for V1 su…
rnovatorov Mar 17, 2026
40d8b73
conductor(plan): Mark phase 'Phase 5: Integration and Finalization' a…
rnovatorov Mar 17, 2026
a99205b
chore(conductor): Mark track 'Implement Rule management (Create, List…
rnovatorov Mar 17, 2026
afb59fa
chore(conductor): Archive track 'Implement Rule management (Create, L…
rnovatorov Mar 17, 2026
667eefa
chore(conductor): Archive track 'Implement Enapter rule-engine rule m…
rnovatorov Mar 17, 2026
709200d
chore(conductor): Drop track 'Add basic unit-tests for the HTTP clien…
rnovatorov Mar 17, 2026
9f9409d
chore(conductor): Final cleanup of track folders
rnovatorov Mar 17, 2026
97e5602
chore(conductor): Initialize track artifacts for Rule Management CLI
rnovatorov Mar 17, 2026
7a6625e
chore(conductor): Add new track 'rule management cli'
rnovatorov Mar 17, 2026
5de1d89
feat(cli): Checkpoint end of Phase 1: CLI Infrastructure and Registra…
rnovatorov Mar 17, 2026
2029002
conductor(plan): Mark phase 'Phase 1: CLI Infrastructure and Registra…
rnovatorov Mar 17, 2026
182fade
feat(cli): Implement Rule Management CLI
rnovatorov Mar 17, 2026
dc63d37
conductor(plan): Mark track 'Rule Management CLI' as complete
rnovatorov Mar 17, 2026
26e8173
chore(conductor): Mark track 'rule management cli' as complete
rnovatorov Mar 17, 2026
04f7fbd
chore(conductor): Archive track 'rule management cli'
rnovatorov Mar 17, 2026
174be10
feat(http-api): Make list_rules an async generator
rnovatorov Mar 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conductor/archive/rule_management_20260311/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Track rule_management_20260311 Context

- [Specification](./spec.md)
- [Implementation Plan](./plan.md)
- [Metadata](./metadata.json)
8 changes: 8 additions & 0 deletions conductor/archive/rule_management_20260311/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"track_id": "rule_management_20260311",
"type": "feature",
"status": "new",
"created_at": "2026-03-11T12:00:00Z",
"updated_at": "2026-03-11T12:00:00Z",
"description": "Implement automation rule management using Enapter HTTP API for Rule Engine (Create, List, Get, Update, Enable, Disable, Delete)."
}
61 changes: 61 additions & 0 deletions conductor/archive/rule_management_20260311/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Implementation Plan: Rule Management

This plan outlines the implementation of Rule management (create, list, get, update, enable/disable, delete) in the Enapter HTTP API Rule Engine client.

## Phase 1: Models and Foundation [checkpoint: c888a5d]

- [x] Task: Define `Rule`, `RuleScript`, and `RuntimeVersion`, and `RuleState` data models
- [x] Create `src/enapter/http/api/rule_engine/rule.py`, `src/enapter/http/api/rule_engine/rule_script.py`, `src/enapter/http/api/rule_engine/runtime_version.py`, and `src/enapter/http/api/rule_engine/rule_state.py`
- [x] Implement `Rule` and `RuleScript` dataclasses and `RuntimeVersion` and `RuleState` enums
- [x] Implement `from_dto` and `to_dto` methods for all models
- [x] Add unit tests for models in `tests/unit/test_http/test_api/test_rule_engine/test_rule.py`
- [x] Task: Export models in `src/enapter/http/api/rule_engine/__init__.py`
- [x] Task: Conductor - User Manual Verification 'Phase 1: Models and Foundation' (Protocol in workflow.md)

## Phase 2: Rule Management Implementation (Read Operations) [checkpoint: 6745120]

- [x] Task: Implement `List Rules` method
- [x] Add `list_rules` method to `src/enapter/http/api/rule_engine/client.py`
- [x] Write failing tests in `tests/unit/test_http/test_api/test_rule_engine/test_client.py`
- [x] Implement method to pass tests
- [x] Task: Implement `Get Rule` method
- [x] Add `get_rule` method to `src/enapter/http/api/rule_engine/client.py`
- [x] Write failing tests
- [x] Implement method to pass tests
- [x] Task: Conductor - User Manual Verification 'Phase 2: Rule Management Implementation (Read Operations)' (Protocol in workflow.md)

## Phase 3: Rule Management Implementation (Write Operations) [checkpoint: 15e657c]

- [x] Task: Implement `Create Rule` method
- [x] Add `create_rule` method to `src/enapter/http/api/rule_engine/client.py`
- [x] Write failing tests (including base64 encoding check)
- [x] Implement method to pass tests
- [x] Task: Implement `Update Rule` (slug) method
- [x] Add `update_rule` method to `src/enapter/http/api/rule_engine/client.py`
- [x] Write failing tests
- [x] Implement method to pass tests
- [x] Task: Implement `Update Rule Script` method
- [x] Add `update_rule_script` method to `src/enapter/http/api/rule_engine/client.py`
- [x] Write failing tests
- [x] Implement method to pass tests
- [x] Task: Implement `Delete Rule` method
- [x] Add `delete_rule` method to `src/enapter/http/api/rule_engine/client.py`
- [x] Write failing tests
- [x] Implement method to pass tests
- [x] Task: Conductor - User Manual Verification 'Phase 3: Rule Management Implementation (Write Operations)' (Protocol in workflow.md)

## Phase 4: Rule State Management [checkpoint: 43df5d0]

- [x] Task: Implement `Enable Rule` and `Disable Rule` methods
- [x] Add `enable_rule` and `disable_rule` methods to `src/enapter/http/api/rule_engine/client.py`
- [x] Write failing tests
- [x] Implement methods to pass tests
- [x] Task: Conductor - User Manual Verification 'Phase 4: Rule State Management' (Protocol in workflow.md)

## Phase 5: Integration and Finalization [checkpoint: 90987b4]

- [x] Task: Add integration tests for all new Rule management methods
- [x] Create `tests/integration/test_rule_engine_management.py` (or similar)
- [x] Verify full flows against a mock or real environment if possible
- [x] Task: Final code quality check (linting, coverage)
- [x] Task: Conductor - User Manual Verification 'Phase 5: Integration and Finalization' (Protocol in workflow.md)
46 changes: 46 additions & 0 deletions conductor/archive/rule_management_20260311/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Specification: Rule Management

## Overview
This track implements comprehensive rule management within the Enapter HTTP API Rule Engine client. This includes creating, listing, retrieving, updating, enabling/disabling, and deleting rules via the Enapter Cloud HTTP API.

## Functional Requirements
The `enapter.http.api.rule_engine.Client` will be extended with methods to:
1. **Create Rule**: `POST` a new rule with a `slug`, `script` (code and runtime version), and optional `disabled` flag.
2. **List Rules**: `GET` all rules for a specific site or the default site.
3. **Get Rule**: `GET` a specific rule by its ID.
4. **Update Rule**: `PATCH` an existing rule's `slug`.
5. **Update Rule Script**: `POST` a new `script` (code and runtime version) for an existing rule.
6. **Enable Rule**: `POST` to enable a rule.
7. **Disable Rule**: `POST` to disable a rule.
8. **Delete Rule**: `DELETE` a rule by its ID.

## Data Model: Rule
A `Rule` model will be introduced in `src/enapter/http/api/rule_engine/rule.py`, including:
- `id`: Unique identifier for the rule.
- `slug`: Human-readable identifier.
- `disabled`: Boolean indicating if the rule is disabled.
- `state`: Execution state (e.g., `STARTED`, `STOPPED`).
- `script`: An object containing:
- `code`: The rule's script code (base64 encoded string).
- `runtime_version`: The runtime environment version (`V1` or `V3`).

## Technical Requirements
- **Integration**: Methods will be added to `enapter.http.api.rule_engine.Client`.
- **Async Strategy**: All API calls will be asynchronous using `httpx.AsyncClient`.
- **Error Handling**: Use the existing `enapter.http.api.check_error` mechanism which raises generic HTTP client exceptions for failed requests.
- **Base64 Encoding**: The client should handle base64 encoding/decoding of the rule script code for ease of use.
- **Modern Python**: Adhere to Python 3.11+ patterns and typing.

## Acceptance Criteria
- [ ] Users can create a rule by providing a slug and script code.
- [ ] Users can list all rules for a site.
- [ ] Users can retrieve a specific rule by ID.
- [ ] Users can update a rule's slug.
- [ ] Users can update a rule's script code and runtime version.
- [ ] Users can enable and disable a rule.
- [ ] Users can delete a rule.
- [ ] All new methods are fully tested with unit and integration tests.

## Out of Scope
- Management of Rule Engine itself (suspend/resume/get state) is already implemented and remains unchanged.
- Frontend/CLI integration for these new methods.
5 changes: 5 additions & 0 deletions conductor/archive/rule_management_cli_20260317/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Track rule_management_cli_20260317 Context

- [Specification](./spec.md)
- [Implementation Plan](./plan.md)
- [Metadata](./metadata.json)
8 changes: 8 additions & 0 deletions conductor/archive/rule_management_cli_20260317/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"track_id": "rule_management_cli_20260317",
"type": "feature",
"status": "new",
"created_at": "2026-03-17T12:00:00Z",
"updated_at": "2026-03-17T12:00:00Z",
"description": "rule management cli"
}
48 changes: 48 additions & 0 deletions conductor/archive/rule_management_cli_20260317/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Implementation Plan: Rule Management CLI

## Phase 1: CLI Infrastructure and Registration [checkpoint: 5de1d89]

- [x] Task: Create `RuleCommand` group and register it
- [x] Create `src/enapter/cli/http/api/rule_command.py`
- [x] Register `RuleCommand` in `src/enapter/cli/http/api/rule_engine_command.py`
- [x] Implement registration of sub-commands (placeholders for now)
- [x] Task: Conductor - User Manual Verification 'Phase 1: CLI Infrastructure and Registration' (Protocol in workflow.md)

## Phase 2: Read Operations (List and Get)

- [x] Task: Implement `rule list` command
- [x] Create `src/enapter/cli/http/api/rule_list_command.py`
- [x] Implement command logic and JSON output
- [x] Task: Implement `rule get` command
- [x] Create `src/enapter/cli/http/api/rule_get_command.py`
- [x] Implement command logic and JSON output
- [x] Task: Conductor - User Manual Verification 'Phase 2: Read Operations (List and Get)' (Protocol in workflow.md)

## Phase 3: Create and Delete Operations

- [x] Task: Implement `rule create` command
- [x] Create `src/enapter/cli/http/api/rule_create_command.py`
- [x] Implement command logic (handle `--script-file`, `--runtime-version`, `--exec-interval`, `--disable`)
- [x] Task: Implement `rule delete` command
- [x] Create `src/enapter/cli/http/api/rule_delete_command.py`
- [x] Implement command logic
- [x] Task: Conductor - User Manual Verification 'Phase 3: Create and Delete Operations' (Protocol in workflow.md)

## Phase 4: Update and State Management Operations

- [x] Task: Implement `rule update` (slug) command
- [x] Create `src/enapter/cli/http/api/rule_update_command.py`
- [x] Implement command logic
- [x] Task: Implement `rule update-script` command
- [x] Create `src/enapter/cli/http/api/rule_update_script_command.py`
- [x] Implement command logic (handle `--script-file`, `--runtime-version`, `--exec-interval`)
- [x] Task: Implement `rule enable` and `rule disable` commands
- [x] Create `src/enapter/cli/http/api/rule_enable_command.py` and `src/enapter/cli/http/api/rule_disable_command.py`
- [x] Implement command logic
- [x] Task: Conductor - User Manual Verification 'Phase 4: Update and State Management Operations' (Protocol in workflow.md)

## Phase 5: Finalization and Quality Check [checkpoint: 182fade]

- [x] Task: Final code quality check (linting)
- [x] Task: Verify overall CLI consistency and help messages
- [x] Task: Conductor - User Manual Verification 'Phase 5: Finalization and Quality Check' (Protocol in workflow.md)
37 changes: 37 additions & 0 deletions conductor/archive/rule_management_cli_20260317/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Specification: Rule Management CLI

## Overview
This track implements a command-line interface for managing rules within the Enapter HTTP API Rule Engine. These commands will be integrated into the existing `enapter` CLI under the `api rule-engine rule` group.

## Functional Requirements
The CLI will be extended with the following commands under `api rule-engine rule`:

1. **List Rules**: `api rule-engine rule list [--site-id SITE_ID]`
2. **Get Rule**: `api rule-engine rule get RULE_ID [--site-id SITE_ID]`
3. **Create Rule**: `api rule-engine rule create --script-file PATH [--slug SLUG] [--site-id SITE_ID] [--disable] [--runtime-version {V1,V3}] [--exec-interval INTERVAL]`
- Creates a new rule. `slug` is optional (autogenerated if missing). `runtime-version` defaults to V3. `exec-interval` required if V1.
4. **Update Rule**: `api rule-engine rule update RULE_ID --slug NEW_SLUG [--site-id SITE_ID]`
- Updates a rule's slug.
5. **Update Rule Script**: `api rule-engine rule update-script RULE_ID --script-file PATH [--site-id SITE_ID] [--runtime-version {V1,V3}] [--exec-interval INTERVAL]`
- Updates a rule's script code and optionally runtime version/interval.
6. **Enable Rule**: `api rule-engine rule enable RULE_ID [--site-id SITE_ID]`
7. **Disable Rule**: `api rule-engine rule disable RULE_ID [--site-id SITE_ID]`
8. **Delete Rule**: `api rule-engine rule delete RULE_ID [--site-id SITE_ID]`

## Technical Requirements
- **Integration**: Commands will be added to `src/enapter/cli/http/api/`.
- **Command Group**: A new `RuleCommand` class will be created and registered within `RuleEngineCommand`.
- **Output**: All commands should output the resulting Rule object in JSON format.
- **Dependency**: Uses the `enapter.http.api.rule_engine.Client`.
- **Script Handling**: Read script file content from `PATH`.

## Acceptance Criteria
- [ ] Users can perform all CRUD operations on rules via the CLI.
- [ ] Users can upload rule scripts from files.
- [ ] Commands support `--site-id` for multi-site management.
- [ ] Output is provided in JSON format.
- [ ] All new CLI commands are covered by manual verification (automated tests skipped per user request).

## Out of Scope
- Downloading rule scripts to files.
- Management of Rule Engine itself (already exists).
10 changes: 0 additions & 10 deletions conductor/tracks.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# Project Tracks

This file tracks all major tracks for the project. Each track has its own detailed plan in its respective folder.

---

- [x] **Track: Add basic unit-tests for the HTTP client.**
*Link: [./tracks/http_client_tests_20260302/](./tracks/http_client_tests_20260302/)*

---

- [x] **Track: Implement Enapter rule-engine rule management in HTTP API client**
*Link: [./tracks/rule_engine_management_20260302/](./tracks/rule_engine_management_20260302/)*
5 changes: 0 additions & 5 deletions conductor/tracks/http_client_tests_20260302/index.md

This file was deleted.

8 changes: 0 additions & 8 deletions conductor/tracks/http_client_tests_20260302/metadata.json

This file was deleted.

17 changes: 0 additions & 17 deletions conductor/tracks/http_client_tests_20260302/plan.md

This file was deleted.

13 changes: 0 additions & 13 deletions conductor/tracks/http_client_tests_20260302/spec.md

This file was deleted.

5 changes: 5 additions & 0 deletions conductor/tracks/rule_management_cli_20260317/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Track rule_management_cli_20260317 Context

- [Specification](./spec.md)
- [Implementation Plan](./plan.md)
- [Metadata](./metadata.json)
8 changes: 8 additions & 0 deletions conductor/tracks/rule_management_cli_20260317/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"track_id": "rule_management_cli_20260317",
"type": "feature",
"status": "new",
"created_at": "2026-03-17T12:00:00Z",
"updated_at": "2026-03-17T12:00:00Z",
"description": "rule management cli"
}
48 changes: 48 additions & 0 deletions conductor/tracks/rule_management_cli_20260317/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Implementation Plan: Rule Management CLI

## Phase 1: CLI Infrastructure and Registration [checkpoint: 5de1d89]

- [x] Task: Create `RuleCommand` group and register it
- [x] Create `src/enapter/cli/http/api/rule_command.py`
- [x] Register `RuleCommand` in `src/enapter/cli/http/api/rule_engine_command.py`
- [x] Implement registration of sub-commands (placeholders for now)
- [x] Task: Conductor - User Manual Verification 'Phase 1: CLI Infrastructure and Registration' (Protocol in workflow.md)

## Phase 2: Read Operations (List and Get)

- [x] Task: Implement `rule list` command
- [x] Create `src/enapter/cli/http/api/rule_list_command.py`
- [x] Implement command logic and JSON output
- [x] Task: Implement `rule get` command
- [x] Create `src/enapter/cli/http/api/rule_get_command.py`
- [x] Implement command logic and JSON output
- [x] Task: Conductor - User Manual Verification 'Phase 2: Read Operations (List and Get)' (Protocol in workflow.md)

## Phase 3: Create and Delete Operations

- [x] Task: Implement `rule create` command
- [x] Create `src/enapter/cli/http/api/rule_create_command.py`
- [x] Implement command logic (handle `--script-file`, `--runtime-version`, `--exec-interval`, `--disable`)
- [x] Task: Implement `rule delete` command
- [x] Create `src/enapter/cli/http/api/rule_delete_command.py`
- [x] Implement command logic
- [x] Task: Conductor - User Manual Verification 'Phase 3: Create and Delete Operations' (Protocol in workflow.md)

## Phase 4: Update and State Management Operations

- [x] Task: Implement `rule update` (slug) command
- [x] Create `src/enapter/cli/http/api/rule_update_command.py`
- [x] Implement command logic
- [x] Task: Implement `rule update-script` command
- [x] Create `src/enapter/cli/http/api/rule_update_script_command.py`
- [x] Implement command logic (handle `--script-file`, `--runtime-version`, `--exec-interval`)
- [x] Task: Implement `rule enable` and `rule disable` commands
- [x] Create `src/enapter/cli/http/api/rule_enable_command.py` and `src/enapter/cli/http/api/rule_disable_command.py`
- [x] Implement command logic
- [x] Task: Conductor - User Manual Verification 'Phase 4: Update and State Management Operations' (Protocol in workflow.md)

## Phase 5: Finalization and Quality Check [checkpoint: 182fade]

- [x] Task: Final code quality check (linting)
- [x] Task: Verify overall CLI consistency and help messages
- [x] Task: Conductor - User Manual Verification 'Phase 5: Finalization and Quality Check' (Protocol in workflow.md)
37 changes: 37 additions & 0 deletions conductor/tracks/rule_management_cli_20260317/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Specification: Rule Management CLI

## Overview
This track implements a command-line interface for managing rules within the Enapter HTTP API Rule Engine. These commands will be integrated into the existing `enapter` CLI under the `api rule-engine rule` group.

## Functional Requirements
The CLI will be extended with the following commands under `api rule-engine rule`:

1. **List Rules**: `api rule-engine rule list [--site-id SITE_ID]`
2. **Get Rule**: `api rule-engine rule get RULE_ID [--site-id SITE_ID]`
3. **Create Rule**: `api rule-engine rule create --script-file PATH [--slug SLUG] [--site-id SITE_ID] [--disable] [--runtime-version {V1,V3}] [--exec-interval INTERVAL]`
- Creates a new rule. `slug` is optional (autogenerated if missing). `runtime-version` defaults to V3. `exec-interval` required if V1.
4. **Update Rule**: `api rule-engine rule update RULE_ID --slug NEW_SLUG [--site-id SITE_ID]`
- Updates a rule's slug.
5. **Update Rule Script**: `api rule-engine rule update-script RULE_ID --script-file PATH [--site-id SITE_ID] [--runtime-version {V1,V3}] [--exec-interval INTERVAL]`
- Updates a rule's script code and optionally runtime version/interval.
6. **Enable Rule**: `api rule-engine rule enable RULE_ID [--site-id SITE_ID]`
7. **Disable Rule**: `api rule-engine rule disable RULE_ID [--site-id SITE_ID]`
8. **Delete Rule**: `api rule-engine rule delete RULE_ID [--site-id SITE_ID]`

## Technical Requirements
- **Integration**: Commands will be added to `src/enapter/cli/http/api/`.
- **Command Group**: A new `RuleCommand` class will be created and registered within `RuleEngineCommand`.
- **Output**: All commands should output the resulting Rule object in JSON format.
- **Dependency**: Uses the `enapter.http.api.rule_engine.Client`.
- **Script Handling**: Read script file content from `PATH`.

## Acceptance Criteria
- [ ] Users can perform all CRUD operations on rules via the CLI.
- [ ] Users can upload rule scripts from files.
- [ ] Commands support `--site-id` for multi-site management.
- [ ] Output is provided in JSON format.
- [ ] All new CLI commands are covered by manual verification (automated tests skipped per user request).

## Out of Scope
- Downloading rule scripts to files.
- Management of Rule Engine itself (already exists).
Loading
Loading