IDE-4857: Add PathRewriteConnector for environment based API path rewriting to make commands work with MEO.#1977
IDE-4857: Add PathRewriteConnector for environment based API path rewriting to make commands work with MEO.#1977vishalkhode1 wants to merge 3 commits intomainfrom
PathRewriteConnector for environment based API path rewriting to make commands work with MEO.#1977Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1977 +/- ##
============================================
+ Coverage 92.34% 92.37% +0.03%
- Complexity 1940 1953 +13
============================================
Files 122 123 +1
Lines 7051 7082 +31
============================================
+ Hits 6511 6542 +31
Misses 540 540 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/1977/acli.phar |
There was a problem hiding this comment.
Pull request overview
This PR introduces a connector decorator to transparently rewrite specific Acquia Cloud API request paths when running in an MEO context (detected via AH_CODEBASE_UUID), and updates connector factory typing accordingly.
Changes:
- Added
PathRewriteConnectorto rewrite/applications/{uuid}/environmentsand/applications/{uuid}/permissionsrequests to codebase-based/translation/codebases/{codebaseUuid}/...endpoints. - Updated
ConnectorFactoryInterface(and implementations) to returnConnectorInterface. - Added PHPUnit coverage for the new connector and the factory behavior when
AH_CODEBASE_UUIDis set/unset.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/phpunit/src/CloudApi/PathRewriteConnectorTest.php | Adds unit tests validating rewrite behavior, passthrough behavior, and missing-env behavior. |
| tests/phpunit/src/CloudApi/ConnectorFactoryTest.php | Adds tests ensuring the factory wraps the connector when AH_CODEBASE_UUID is set. |
| src/ConnectorFactoryInterface.php | Simplifies the factory contract to return ConnectorInterface. |
| src/CloudApi/PathRewriteConnector.php | Introduces the connector decorator that performs regex-based path rewrites. |
| src/CloudApi/ConnectorFactory.php | Wraps the created connector with PathRewriteConnector when AH_CODEBASE_UUID is present; refactors connector construction into buildConnector(). |
| src/AcsfApi/AcsfConnectorFactory.php | Aligns the ACSF connector factory return type with the updated interface (ConnectorInterface). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PathRewriteConnector for environment based API path rewriting to make commands work with MEO.
PathRewriteConnector for environment based API path rewriting to make commands work with MEO.PathRewriteConnector for environment based API path rewriting to make commands work with MEO.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Motivation
The Cloud API endpoints differ for MEO subscriptions, requiring path rewriting for certain endpoints (e.g.,
/applications/{uuid}/permissions→/translation/codebases/{codeBaseUuid}/permissions). This PR introduces a transparent, environment-driven path rewriting mechanism to ensure compatibility and reduce code duplication.Proposed changes
PathRewriteConnector, a decorator forConnectorInterfacethat rewrites API paths based on regex rules and theAH_CODEBASE_UUIDenvironment variable.ConnectorFactoryto wrap connectors withPathRewriteConnectorwhen the environment variable is set.Alternatives considered
Testing steps
vendor/bin/phpunitto verify all tests pass and coverage is 100% for new logic.AH_CODEBASE_UUIDin your environment and verify that API calls are rewritten only when expected.ide:wizards:ssh-key:create-upload) for both MEO and non-MEO subscriptions to confirm correct endpoint usage and output../bin/acli ckc