Iter-14: Pull zone edge rule management#18
Conversation
Adds edge rule CRUD on pull zones: list, add, update (upsert),
delete, and enable/disable. Edge rules drive URL rewrites,
redirects, header manipulation, origin overrides, and request
blocking at the CDN edge.
- bunny-api-core: EdgeRule, EdgeRuleTrigger, EdgeRuleActionType,
TriggerType enums plus three new client methods
(add_or_update_edge_rule, delete_edge_rule, set_edge_rule_enabled)
- CLI: hoppy pull-zone edge-rule {list,add,update,delete,enable}
with --trigger type:patterns repeatable syntax
- Tests: wiremock + insta snapshots for list/add/delete/enable
and a live-api E2E lifecycle test
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds full Pull Zone edge rule support: new API client endpoints, edge-rule types and request builders, CLI subcommands/handlers for listing/adding/updating/deleting/enabling rules with trigger parsing, fixtures and tests (API and CLI), and documentation status update. ChangesEdge Rules Feature
Sequence DiagramsequenceDiagram
actor User
participant CLI as CLI Handler
participant Parser as Trigger Parser
participant Builder as Request Builder
participant Client as API Client
participant Server as Bunny API
User->>CLI: hoppy pullzone edge-rule add --id 123 --action-type redirect --trigger "url:*/old-path*" --action-param1 /new-path
CLI->>Parser: parse_trigger("url:*/old-path*")
Parser->>Parser: split type and patterns
Parser-->>CLI: EdgeRuleTrigger
CLI->>Builder: build_edge_rule_body(action_type, triggers, ...)
Builder->>Builder: construct AddOrUpdateEdgeRule
Builder-->>CLI: request body
CLI->>Client: add_or_update_edge_rule(123, body)
Client->>Server: POST /pullzone/123/edgerules/addOrUpdate
Server-->>Client: 200 OK (empty)
Client-->>CLI: Result<()>
CLI-->>User: "Edge rule added"
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds pull zone edge rule management to Hoppy, wiring new bunny.net edge rule API support in bunny-api-core through to new hoppy pull-zone edge-rule ... CLI subcommands, along with fixtures and tests to validate behavior.
Changes:
- Introduce edge rule request/response types and client methods in
bunny-api-core(upsert, delete, enable/disable) and deserializePullZone.EdgeRules. - Add CLI support for
pull-zone edge-rule {list, add, update, delete, enable}plus trigger parsing and table/JSON output formatting. - Expand test coverage with new fixtures, wiremock tests, snapshots, and a live-api lifecycle test.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/snapshots/cli_pull_zone__pull_zone_list_json.snap | Updates pull zone list JSON snapshot to include EdgeRules. |
| tests/snapshots/cli_pull_zone__pull_zone_get_json.snap | Updates pull zone get JSON snapshot to include EdgeRules. |
| tests/snapshots/cli_pull_zone__pull_zone_create_json.snap | Updates pull zone create JSON snapshot to include EdgeRules. |
| tests/snapshots/cli_pull_zone__pull_zone_edge_rule_list_table.snap | New snapshot for edge rule list table output. |
| tests/snapshots/cli_pull_zone__pull_zone_edge_rule_list_json.snap | New snapshot for edge rule list JSON output. |
| tests/cli_pull_zone.rs | Adds wiremock tests + snapshots for edge rules and a live-api edge rule lifecycle test. |
| src/commands/pull_zone.rs | Implements edge rule subcommand handling (list/add/update/delete/enable) and trigger parsing. |
| src/cli.rs | Adds pull-zone edge-rule clap subcommands and flags. |
| hoppy-knowledgebase/iterations/iteration-14-edge-rules.md | Marks iteration 14 work as completed and checks off tasks. |
| fixtures/core/pullzone_get_with_edgerules.json | New fixture containing EdgeRules data for list/get tests. |
| fixtures/core/pullzone_edgerule_add.json | New edge rule fixture payload. |
| crates/bunny-api-core/tests/pullzone_api.rs | Adds unit tests for edge rule endpoints and edge rule deserialization. |
| crates/bunny-api-core/src/types.rs | Adds edge rule enums/models + AddOrUpdateEdgeRule, and adds edge_rules to PullZone. |
| crates/bunny-api-core/src/lib.rs | Re-exports new edge rule types. |
| crates/bunny-api-core/src/client.rs | Adds edge rule client methods (upsert, delete, enable/disable). |
| #[arg(long)] | ||
| rule_id: String, | ||
| /// Whether to enable (true) or disable (false) the rule | ||
| #[arg(long)] |
| "--rule-id", | ||
| &guid, | ||
| "--enabled", | ||
| "false", | ||
| ]); |
| let pz = client.get_pull_zone(*id).await?; | ||
| if let OutputFormat::Json = format { | ||
| let json = serde_json::to_string_pretty(&pz.edge_rules) | ||
| .expect("failed to serialize to JSON"); |
- src/cli.rs: --enabled now uses ArgAction::Set so users can pass --enabled true/false (matches the help text and the pattern used by hostname force-ssl). Reported by Copilot, CodeRabbit, and local. - tests/cli_pull_zone.rs: mock enable test now passes "true" as the flag value to match the new arg syntax. - src/commands/pull_zone.rs: replace .expect() with .context()? for edge rule list JSON serialization, per the project rule against panicking outside tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
hoppy pull-zone edge-rule {list, add, update, delete, enable}with repeatable--trigger type:pat1,pat2syntax. Add omits Guid (creates), update requires--rule-id(upserts).Test plan
Summary by CodeRabbit
New Features
Tests
Documentation
Chores