feat: add workspace add-api and list-apis commands#254
Conversation
Non-interactive command to subscribe API service(s) to a workspace by service code. Completes the CLI-driven project setup workflow alongside `project create` and `workspace create`, enabling fully scripted and agentic App Builder project bootstrapping. Usage: aio console workspace add-api \ --projectName myproject \ --workspaceName dev \ --service-code AdobeAnalyticsSDK,CloudIntegrationSDK
Companion to `add-api` — lists all enabled API service codes for the selected Organization so users can discover valid --service-code values. Supports --json and --yml output flags.
Fixes 100% coverage threshold for statements, branches, and lines.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
JIRA: ACNA-4538 |
There was a problem hiding this comment.
Pull request overview
Adds two new non-interactive Workspace CLI commands to support API discovery and subscription during project bootstrap.
Changes:
- Introduces
aio console workspace list-apisto list enabled API services (supports--json/--yml). - Introduces
aio console workspace add-apito subscribe one or more API services (by service code) to a workspace using OAuth S2S credentials. - Adds unit test coverage for both commands, including output formats, config fallback behavior, and error handling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/commands/console/workspace/list-apis.js | Implements list-apis command to fetch and print enabled services for an org in text/JSON/YAML forms. |
| src/commands/console/workspace/add-api.js | Implements add-api command to resolve project/workspace by name, validate service codes against org-enabled services, and subscribe via the SDK. |
| test/commands/console/workspace/list-apis.test.js | Adds unit tests covering standard output, JSON/YAML output, empty list handling, config fallback, and SDK error propagation. |
| test/commands/console/workspace/add-api.test.js | Adds unit tests covering single/multiple subscriptions, null service properties, validation errors, config fallback, required flags, output formats, and SDK failure behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Considering the syntax of the other commands this seems odd. |
|
APIs are limited to workspaces correct? Maybe we make it stick to a subset of aio console workspace ? |
|
just a thought @pru55e11 - we could add the pr-review.yml like this one so the Github review bot can be enabled. Since that's a one-time manual set up per repo, each repo would still need that workflow file added |
Restructures per review feedback on PR #254: - Moves `console workspace add-api` -> `console workspace api add` - Replaces `console workspace list-apis` with two distinct commands: - `console api list` for APIs available to the org - `console workspace api list` for APIs subscribed to a workspace Adds `--license-config <sdkCode>=<profileNameOrId>[,...]` (repeatable) to support services that require product profiles (e.g. AdobeAnalyticsSDK). Profiles match by id or name. When a service requires profiles but none are provided, the error lists the available profiles so users can pick. `console api list` now flags services that require a product profile to aid discovery. 55 new tests across 5 suites; 100% coverage on all new files.
|
Thanks for the feedback @purplecabbage -- pushed 1faad22 addressing all three points. Restructured under
|
| Old | New |
|---|---|
console workspace add-api |
console workspace api add |
console workspace list-apis |
split into two: |
console api list -- APIs available to the org |
|
console workspace api list -- APIs subscribed to the workspace |
Aliases: console:ws:api:add, console:api:ls, console:ws:api:list/ls.
Product profile support
Added repeatable --license-config '<sdkCode>=<profileNameOrId>[,...]'. Profiles match by id or name.
If a service requires profiles but none are passed, the error lists them:
```
$ aio console workspace api add --service-code AdobeAnalyticsSDK --projectName x --workspaceName dev
› Error: The following service(s) require one or more product profiles. Pass them with --license-config '=[,...]':
› AdobeAnalyticsSDK: Analytics all access, Analytics - Adobe IO DEMO, ProductProfileTest, ...
```
console api list also flags which services need a profile:
```
AdobeAnalyticsSDK
Name: Adobe Analytics
Requires product profile: yes
```
Tested against AdobeAnalyticsSDK
```
$ aio console workspace api add --projectName acna4538test --workspaceName dev
--service-code AdobeAnalyticsSDK
--license-config 'AdobeAnalyticsSDK=Analytics - Adobe IO DEMO' --json
{ "sdkList": ["AdobeAnalyticsSDK"] }
$ aio console workspace api list --projectName acna4538test --workspaceName dev
API services subscribed to Workspace dev (1):
AdobeAnalyticsSDK
Name: Adobe Analytics
Product Profiles: Analytics - Adobe IO DEMO
```
Bogus profile name produces a clean error with the available list.
Known behavior worth flagging (not changed here)
The underlying subscribeCredentialToServices SDK call replaces the credential's full service list rather than appending. So api add with one service will drop others that were previously subscribed on the same credential. That matches how aio app add service behaves too, so I left it consistent. Happy to add a --merge flag that pre-fetches via getServicePropertiesFromWorkspace and unions in a follow-up if you want that as default.
There was a problem hiding this comment.
🤖 PR Reviewer
The new commands and tests are well-structured, follow existing patterns, and have good test coverage. A few minor issues exist: project/workspace lookups do O(N) linear searches that could be simplified with clearer error messaging, and there's one edge case where this.error() is called inside the try block which oclif re-wraps with this.error() in the catch block potentially double-wrapping errors. The copyright year 2026 in all files appears to be a typo.
✅ LGTM! This PR looks good to merge.
💡 How to re-trigger
Comment /review or /pr-reviewer on this PR
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Adds non-interactive CLI commands for discovering API services and subscribing them to a Workspace, under a new
apitopic for consistency:aio console api list— list API services available to the org (discover valid service codes). Flags services that require a product profile.aio console workspace api list— list API services currently subscribed to a Workspace.aio console workspace api add— subscribe one or more API services to a Workspace by service code, using OAuth S2S credentials. Supports product profiles via repeatable--license-config '<sdkCode>=<profileNameOrId>[,...]'.All commands resolve project/workspace by name and support
--json/--ymloutput.Together these complete the fully non-interactive project bootstrap workflow:
Closes ACNA-4538
Test plan
AppBuilderDataServicesSDK)AppBuilderDataServicesSDK,AdobeIOManagementAPISDK)api listreturns all 35 enabled org services and flags profile-required onesworkspace api addwithAdobeAnalyticsSDKand--license-config 'AdobeAnalyticsSDK=Analytics - Adobe IO DEMO'subscribes with the correct profileworkspace api listreflects current subscriptions including product profiles