Skip to content

[Do not Merge] CLI-1793: Consume Cloud API v3 OpenAPI spec in ACLI (#2011) - #2018

Draft
deepakmishra2 wants to merge 10 commits into
mainfrom
feature/meo-v3-gateway
Draft

[Do not Merge] CLI-1793: Consume Cloud API v3 OpenAPI spec in ACLI (#2011)#2018
deepakmishra2 wants to merge 10 commits into
mainfrom
feature/meo-v3-gateway

Conversation

@deepakmishra2

@deepakmishra2 deepakmishra2 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces initial support for Acquia Cloud API v3 (MEO) command generation, including infrastructure for handling OpenAPI 3.1+ specs, new service wiring, and improved handling of command stability and filtering. It also adds automation for updating the v3 spec and includes related tests and minor bugfixes.

Acquia Cloud API v3 support:

  • Added new V3ClientService, ApiV3CommandFactory, and ApiV3CommandHelper classes to support v3 commands, which use the v3 OpenAPI spec and resolve their base URI via the new getV3BaseUri() method in CloudCredentials. These helpers override extension-field lookups and operation filtering to match v3 spec conventions. [1] [2] [3] [4]
  • Registered new v3 services in config/prod/services.yml for dependency injection, ensuring v3 commands use the correct credentials and endpoints.

API command generation and stability handling:

  • Refactored command generation to delegate CLI command name, stability, and filtering logic to overridable helper methods, enabling v3 and v2 to coexist and diverge as needed. Command stability is now surfaced in descriptions and as a runtime warning for non-production commands. [1] [2] [3] [4] [5]
  • Improved namespace detection and filtering for command and list generation, making the logic more robust for future API versions. [1] [2] [3]

Automation and testing:

  • Added a GitHub Actions workflow to automatically download, convert, and commit updates to the v3 OpenAPI spec. [1] [2]
  • Added unit tests for new v3 service construction and environment variable handling. [1] [2] [3]

Bugfixes and minor improvements:

  • Fixed IDE create command to return failure if the IDE is not created, and improved comments for test coverage.
  • Improved namespace handling in the self-update list command for better compatibility.

* Bump the dependencies group with 2 updates (#2010)

Bumps the dependencies group with 2 updates: [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) and [ramsey/uuid](https://github.com/ramsey/uuid).

Updates `guzzlehttp/guzzle` from 7.11.1 to 7.12.1
- [Release notes](https://github.com/guzzle/guzzle/releases)
- [Changelog](https://github.com/guzzle/guzzle/blob/7.12/CHANGELOG.md)
- [Commits](guzzle/guzzle@7.11.1...7.12.1)

Updates `ramsey/uuid` from 4.9.2 to 4.9.3
- [Release notes](https://github.com/ramsey/uuid/releases)
- [Changelog](https://github.com/ramsey/uuid/blob/4.x/CHANGELOG.md)
- [Commits](ramsey/uuid@4.9.2...4.9.3)

---
updated-dependencies:
- dependency-name: guzzlehttp/guzzle
  dependency-version: 7.12.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
- dependency-name: ramsey/uuid
  dependency-version: 4.9.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* CLI-1793: Spike — POC to consume Cloud API v3 OpenAPI spec in ACLI

Adds a parallel command-generation path for v3 specs sourced from
`acquia/api-specs`, without touching the existing v2 or ACSF pipelines.

- composer.json: new `update-acquia-v3-spec` script that bundles
  site-service-php + environment-service-php via redocly, then
  translates legacy `x-cli-name` to ARB-550's
  `x-acquia-exposure.channels.cli.command` at the consumption boundary.
- src/Command/Api/ApiCommandHelper.php: extracted `getCliCommandName()`
  and `normalizePath()` as protected template methods. v2 behavior
  unchanged (defaults return legacy key / input path).
- src/Command/Api/ApiV3CommandHelper.php: subclass with strict ARB-550
  key lookup (no legacy fallback) and `/v3/` path prefixing for
  env-service endpoints (site-service endpoints are not prefixed on
  the live gateway and are left untouched).
- bin/acli: register `api:v3:*` commands under a `file_exists` guard,
  reusing the existing `ApiCommandFactory`.
- assets/acquia-v3-spec.json: first v3 bundle (20 operations across
  site-service-php + environment-service-php).
- docs/poc/acquia-v3-spec-ingestion.md: findings doc with go/no-go
  recommendation, upstream dependency tracking (API-1678 KaaS server,
  API-1674 CLI directive, acquia/api-specs PR #46 bundling fixes),
  and a cleanup plan for each jq transform once upstream catches up.

Tests: 32 pass / 159 assertions. 4 ARB-550 key cases, 4 path
normalization cases, 6 spec-file sanity checks, 5 real-bundle E2E
tests, plus v2 regression coverage via ApiCommandHelperTest and
ApiListCommandTest.

Live-verified end-to-end:
- `api:v3:environments:find <uuid>` returns 200 OK with real MEO env
  data from the production Cloud Platform gateway.
- `api:v3:sites:duplicate` accepted (202) and created a real
  duplicated site.
- No regressions on `api:*` (378 v2 commands) or `acsf:*` (128 commands).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix mutation testing.

* fix test and v3 changes.

* fix site instance issue.

* Fix gateway url and logic update.

* mutation test added

* fix cves.

* fix test.

* fix test

* feedback changes.

* update spec.

* add more test.

* add stability flag

* mutation testing fix.

* mutation test fix.

* logic for audience added.

* mutation fix again

* update make redocly call

* CLI-1796: Productionize the v3 commands for CLI. (#2013)

* CLI-1796: Productionize the v3 commands for CLI.

* fix CI.

* remove CI logic.

* ran composer command to update spec.

* update git ssh url.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@deepakmishra2
deepakmishra2 force-pushed the feature/meo-v3-gateway branch from 33243c5 to c2df57a Compare July 10, 2026 10:21
@deepakmishra2 deepakmishra2 self-assigned this Jul 10, 2026
@deepakmishra2 deepakmishra2 added the breaking change Requires change record label Jul 10, 2026
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.57143% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.53%. Comparing base (b3ac77e) to head (a8afcf8).

Files with missing lines Patch % Lines
src/Command/Ide/IdeCreateCommand.php 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2018      +/-   ##
============================================
+ Coverage     92.49%   92.53%   +0.03%     
- Complexity     1995     2018      +23     
============================================
  Files           123      126       +3     
  Lines          7238     7296      +58     
============================================
+ Hits           6695     6751      +56     
- Misses          543      545       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Try the dev build for this PR: https://acquia-cli.s3.amazonaws.com/build/pr/2018/acli.phar

curl -OL https://acquia-cli.s3.amazonaws.com/build/pr/2018/acli.phar
chmod +x acli.phar

deepakmishra2 and others added 6 commits July 15, 2026 11:44
Adds a GitHub Actions workflow (.github/workflows/update-v3-spec.yml)
that runs daily at 03:00 UTC (and supports workflow_dispatch). It fetches
the latest v3 OpenAPI spec from the gateway URL, converts YAML to JSON,
and auto-creates + auto-merges a PR when the spec changes.

Removes the old update-acquia-v3-spec composer script (npm/git-clone
approach) since the workflow replaces it.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
GITHUB_TOKEN cannot trigger CI on automated PRs; a PAT stored as
GH_TOKEN is required for workflow runs to start on the created PR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@deepakmishra2

Copy link
Copy Markdown
Contributor Author

@copilot can you resolve the conflict?

Copilot AI added 2 commits July 24, 2026 12:00
Resolve conflicts:
- ApiBaseCommand.php: take CLI-1779 fix (POST-only empty-body guard)
- ApiCommandTest.php: keep both testPostWithBodyDoesNotSendEmptyFallback and testBodylessPutDoesNotSendEmptyJsonBody

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown

@copilot can you resolve the conflict?

Resolved. The two conflicts were:

  1. src/Command/Api/ApiBaseCommand.php — took the CLI-1779 fix from main: the empty-body JSON fallback is now restricted to POST only (not PUT/PATCH), since Guzzle creates a non-seekable stream for an empty stdClass on PUT/PATCH requests.

  2. tests/phpunit/src/Commands/Api/ApiCommandTest.php — kept both test methods: testPostWithBodyDoesNotSendEmptyFallback (from the feature branch) and testBodylessPutDoesNotSendEmptyJsonBody (from main), as they test complementary scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Requires change record

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants