Skip to content

CLI-1711: [NCI] Database and File commands support#1961

Merged
jigar-shah-acquia merged 45 commits intomainfrom
CLI-1711
Feb 11, 2026
Merged

CLI-1711: [NCI] Database and File commands support#1961
jigar-shah-acquia merged 45 commits intomainfrom
CLI-1711

Conversation

@jigar-shah-acquia
Copy link
Contributor

Motivation

This change adds support for NCI database, file, and environment commands in ACLI. These commands enable internal workflows for managing site instances, including database backups, database and file copy operations, environment log creation, and Varnish cache clearing, without exposing raw API endpoints directly to customers.

This work also cleans up previous non-standard API spec handling and aligns ACLI with service-owned and cx-api-spec definitions.

Fixes CLI-1711


Proposed Changes

  • Implement support for the following custom ACLI commands:
    • api:environment-v3:log-create
    • api:environments-v3:clear-caches
    • api:environments-v3:log-list
    • api:environments-v3:log-download
    • api:environments-v3:code-switch
    • api:site-instances:database:backups:create
    • api:site-instances:database:copy
    • api:site-instances:files:copy
  • Remove non-cx-api-spec additions previously committed to acquia-spec.json (from PR CLI-1696: MEO commands #1955).
  • Move non-standard/generated API specs into a secure GitHub Actions secret instead of version control.
  • Update the build process to merge API specs from secrets with existing stable specs.
  • Remove _links from API responses to align with expected CLI output.
  • Mark these commands as deprecated so they are not exposed directly to customers.
  • Add and validate a hand-rolled OpenAPI spec (post-log-openapi.json) for environment log creation.
  • Address issues identified via mutation testing and improve overall test coverage.

Alternatives Considered

  • Exposing raw API endpoints directly through ACLI was considered but rejected to avoid exposing unstable or internal APIs to customers.
  • Using only backend service OpenAPI specs was considered, but cx-api-spec was preferred for stability and consistency where available.

Testing Steps

  1. Follow the contribution guide to set up the development environment or download a pre-built acli.phar.
  2. If running from source, clear the kernel cache to load new and updated commands:
    ./bin/acli ckc
  3. Run the existing CLI test suite to check for regressions.
  4. Validate new functionality:
  • Create a database backup for a site instance.
  • Perform database copy between site instances.
  • Perform file copy between site instances.
  • Create environment logs using the translation-based endpoint.
  • Attempt to clear Varnish cache (note: may be blocked due to N3 proxy limitations).
  1. Verify command output formatting, error handling, and schema validation align with ACLI standards.

@jigar-shah-acquia jigar-shah-acquia self-assigned this Feb 10, 2026
@jigar-shah-acquia jigar-shah-acquia marked this pull request as ready for review February 10, 2026 21:32
Copilot AI review requested due to automatic review settings February 10, 2026 21:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements support for NCI (non-customer-interfacing) database, file, and environment commands in ACLI, enabling internal workflows for managing site instances. The changes remove previously added non-standard API specifications from version control and instead load them from GitHub Actions secrets during the build process.

Changes:

  • Remove deprecated mungeResponse() method and translation endpoint handling logic
  • Delete non-cx-api-spec OpenAPI definitions for translation endpoints from acquia-spec.json
  • Add GitHub Actions workflow steps to merge additional API specs from secrets into the base specification file

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/phpunit/src/Commands/Api/ApiCommandTest.php Removes test for translation response munging that stripped _links fields
src/Command/Api/ApiBaseCommand.php Removes translation path detection and response munging logic from command execution
assets/acquia-spec.json Removes OpenAPI definitions for deprecated translation endpoints (log-list, log-download, code-switch)
.github/workflows/ci.yml Adds workflow steps to extract and merge additional API specs from GitHub secrets during build

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

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

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

Copy link

@anujkaushal anujkaushal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

➜  acli_dump ./acli.phar api:environments-v3:log-create --from "2026-02-02T00:00:00.000Z" --to "2026-02-02T10:00:00.000Z" RETRACTED cronjob
{
    "message": "The log file is being created.",
    "_links": {
        "self": {
            "href": "https:\/\/staging.cloud.acquia.com\/api\/environments\/RETRACTED\/logs\/cronjob"
        },
        "parent": {
            "href": "https:\/\/staging.cloud.acquia.com\/api\/environments\/RETRACTED\/logs"
        },
        "notification": {
            "href": "https:\/\/staging.cloud.acquia.com\/api\/notifications\/RETRACTED"
        }
    }
}

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.28%. Comparing base (481e78d) to head (975c0db).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1961   +/-   ##
=========================================
  Coverage     92.28%   92.28%           
+ Complexity     1916     1910    -6     
=========================================
  Files           122      122           
  Lines          6995     6987    -8     
=========================================
- Hits           6455     6448    -7     
+ Misses          540      539    -1     

☔ View full report in Codecov by Sentry.
📢 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.

@jigar-shah-acquia jigar-shah-acquia merged commit 5b44af7 into main Feb 11, 2026
26 checks passed
@jigar-shah-acquia jigar-shah-acquia deleted the CLI-1711 branch February 11, 2026 07:55
}

if (substr($this->path, 0, 12) === '/translation') {
$this->mungeResponse($response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to result in the embedded links appearing in translation API responses again? @shriacquia is this what you intended? Seems like this is going to cause enormous confusion for the customer and concern for Alan and team.

I wish I'd had a chance to re-review this PR after requesting changes on it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Links should not be sent to the client as mentioned also in the implementation details that I had to put in.

Copy link
Contributor Author

@jigar-shah-acquia jigar-shah-acquia Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have implemented this change and created the corresponding ticket and PR for it.
https://acquia.atlassian.net/browse/CLI-1729
#1962

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants