iter-26: expose Bunny Optimizer pull zone settings#31
Conversation
Add the full Optimizer configuration surface to PullZone (response) and UpdatePullZone (request), plus 23 --optimizer-* flags on `pull-zone update`. Operators can now configure Optimizer end-to-end without falling back to raw curl. - 24 fields on PullZone (incl. read-only OptimizerPricing as f64) - 23 writable fields mirrored on UpdatePullZone - OptimizerWatermarkPosition repr-enum with kebab-case CLI parsing - deserialize_string_lossy_option helper for OptimizerClasses (live API returns [] when empty, plan/docs say string) - OptimizerPricing typed as Option<f64> not i32 — fixture shows 9.5 - Wiremock + CLI tests covering: only-set-fields serialisation, false-not-skipped, OptimizerMinifyJavaScript long-form key, watermark-position-as-int, full round-trip Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds comprehensive support for Bunny Optimizer pull zone settings by extending API types and serde handling, adding CLI flags and handler wiring, introducing e2e and unit tests with fixtures, and updating documentation. ChangesOptimizer Settings Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 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 expands Hoppy’s bunny-api-core Pull Zone models and CLI to expose bunny.net “Optimizer” configuration end-to-end (read via PullZone, write via UpdatePullZone, and CLI flags on pull-zone update), including handling a known API quirk for OptimizerClasses.
Changes:
- Add Optimizer fields to
PullZone(response) andUpdatePullZone(request), including a new repr-basedOptimizerWatermarkPositionenum and explicit wire renames for irregular keys likeOptimizerMinifyCSS/OptimizerMinifyJavaScript. - Extend
hoppy pull-zone updatewith--optimizer-*flags (grouped under an “Optimizer” help heading) and anafter_helpexample; wire flags to request body fields. - Add fixtures + wiremock/CLI tests for round-tripping Optimizer-rich responses and verifying request bodies only include explicitly set Optimizer fields; update e2e JSON snapshots accordingly.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/snapshots/e2e__cli_pull_zone__pull_zone_list_json.snap | Snapshot updated to include Optimizer fields in list JSON output. |
| tests/e2e/snapshots/e2e__cli_pull_zone__pull_zone_get_json.snap | Snapshot updated to include Optimizer fields in get JSON output. |
| tests/e2e/snapshots/e2e__cli_pull_zone__pull_zone_create_json.snap | Snapshot updated to include Optimizer fields surfaced on created zone JSON output. |
| tests/e2e/cli_pull_zone.rs | Adds CLI integration test asserting pull-zone update --optimizer-* flags map to correct wire keys/values. |
| src/commands/pull_zone.rs | Wires new CLI args into UpdatePullZone request construction for pull zone updates. |
| src/cli.rs | Adds --optimizer-* flags and a CLI-only watermark position enum (ValueEnum) plus usage examples. |
| hoppy-knowledgebase/iterations/iteration-26-optimizer-settings.md | Iteration record documenting scope, fields, flags, and tests for Optimizer support. |
| hoppy-knowledgebase/decision-log.md | Records decision to ship full Optimizer surface in one iteration. |
| hoppy-knowledgebase/api/bunny-api-quirks.md | Documents Optimizer API quirks (classes empty array, pricing float, enum may grow, CSS key casing). |
| fixtures/core/pullzone_get_with_optimizer.json | Adds Optimizer-rich fixture used to validate deserialization/serialization behavior. |
| crates/bunny-api-core/tests/e2e/pullzone_api.rs | Adds wiremock tests for Optimizer write semantics and Optimizer-rich read round-trip. |
| crates/bunny-api-core/src/types.rs | Adds Optimizer fields to PullZone/UpdatePullZone and introduces OptimizerWatermarkPosition repr-enum. |
| crates/bunny-api-core/src/serde_helpers.rs | Adds deserialize_string_lossy_option helper + unit tests to tolerate non-string OptimizerClasses. |
| crates/bunny-api-core/src/lib.rs | Re-exports OptimizerWatermarkPosition from the core types module. |
| /// Bunny.net may add new positions in future API versions. The CLI uses | ||
| /// [`crate::serde_helpers::deserialize_repr_option`] so unknown values | ||
| /// deserialise to `None` instead of failing. |
| **Watermark** | ||
| - [x] `optimizer_watermark_enabled: Option<bool>` | ||
| - [x] `optimizer_watermark_url: Option<String>` | ||
| - [x] `optimizer_watermark_position: Option<i32>` (enum: top-left=0, top-right=1, bottom-left=2, bottom-right=3, center=4 — confirm against spec) |
| - [x] `optimizer_tunnel_enabled: Option<bool>` | ||
|
|
||
| **Read-only (response only — do NOT add to `UpdatePullZone`)** | ||
| - [x] `optimizer_pricing: Option<i32>` — appears to be a server-set tier indicator |
- Reword OptimizerWatermarkPosition docstring to describe the repr-enum forward-compat pattern as a property of the PullZone field deserializer, not the CLI. - Update iteration plan to reflect the actual implemented types: optimizer_watermark_position is the OptimizerWatermarkPosition repr-enum, optimizer_pricing is Option<f64> (server returns floats like 9.5). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Optimizer*fields fromPullZoneModeltoPullZone(response) and the 23 writable ones toUpdatePullZone(request);OptimizerPricingstays read-only.--optimizer-*flags topull-zone updateunder an "Optimizer" help heading, plus anafter_helpexample. NewOptimizerWatermarkPositionrepr-enum (kebab-case CLI, integer wire).deserialize_string_lossy_optionserde helper so existing fixtures (OptimizerClasses: []) keep deserialising while the writable type staysOption<String>.OptimizerMinifyJavaScriptlong-form key, watermark-position serialised as int) and a CLI integration test asserting the wire body.Plan deviations
OptimizerPricingtyped asOption<f64>(notOption<i32>as the plan suggested) — the livepullzone_get.jsonfixture shows9.5, so it's a float.OptimizerClassesleft asOption<String>per plan, but read-side uses a lenient deserializer that maps non-string values (incl. empty array[]) toNoneto keep existing fixtures working.Test plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace --quiethoppy pull-zone update --help— verify the Optimizer help heading and grouped flagshoppy pull-zone get --id <id> --format jsonagainst a real zone — verify all Optimizer fields surface🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Behavior
Tests
Documentation