Skip to content

feat: add workspace add-api and list-apis commands#254

Merged
pru55e11 merged 5 commits intomasterfrom
feat/workspace-add-api
Apr 20, 2026
Merged

feat: add workspace add-api and list-apis commands#254
pru55e11 merged 5 commits intomasterfrom
feat/workspace-add-api

Conversation

@pru55e11
Copy link
Copy Markdown
Contributor

@pru55e11 pru55e11 commented Apr 17, 2026

Summary

Adds non-interactive CLI commands for discovering API services and subscribing them to a Workspace, under a new api topic 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 / --yml output.

Together these complete the fully non-interactive project bootstrap workflow:

aio console org select $ORG_ID
aio console project create -n myproject
aio console workspace create --projectName myproject --name dev
aio console api list --json
aio console workspace api add --projectName myproject --workspaceName dev \
  --service-code AppBuilderDataServicesSDK
# for services that require a product profile:
aio console workspace api add --projectName myproject --workspaceName dev \
  --service-code AdobeAnalyticsSDK \
  --license-config 'AdobeAnalyticsSDK=Analytics - Adobe IO DEMO'
aio app init myapp -w dev -p myproject -y

Closes ACNA-4538

Test plan

  • Unit tests: 55 tests across 5 new suites, 100% coverage on all new files
  • Manual: tested against Adobe IO org with fresh project/workspace
    • Single API subscription (AppBuilderDataServicesSDK)
    • Multiple APIs in one call (AppBuilderDataServicesSDK,AdobeIOManagementAPISDK)
    • Idempotent re-runs (skips credential creation, re-attaches cleanly)
    • Invalid service code produces clean error
    • api list returns all 35 enabled org services and flags profile-required ones
    • workspace api add with AdobeAnalyticsSDK and --license-config 'AdobeAnalyticsSDK=Analytics - Adobe IO DEMO' subscribes with the correct profile
    • Missing profile for a service that requires one produces a clean error listing available profiles
    • Unknown profile name produces a clean error listing available profiles
    • workspace api list reflects current subscriptions including product profiles

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
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pru55e11
Copy link
Copy Markdown
Contributor Author

JIRA: ACNA-4538

Copy link
Copy Markdown

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

Adds two new non-interactive Workspace CLI commands to support API discovery and subscription during project bootstrap.

Changes:

  • Introduces aio console workspace list-apis to list enabled API services (supports --json / --yml).
  • Introduces aio console workspace add-api to 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.

@purplecabbage
Copy link
Copy Markdown
Member

Considering the syntax of the other commands this seems odd.

aio console org list             : list orgs of current user
aio console project list         : list projects in selected org 
aio console workspace list       : list workspace in selected project
aio console api list             : list apis available to user in org
aio console workspace api list   : list api installed to workspace

aio console workspace add-api    : add specified api to workspace
aio console workspace delete-api   ??

@pru55e11
Copy link
Copy Markdown
Contributor Author

APIs are limited to workspaces correct? Maybe we make it stick to a subset of aio console workspace ?

@dthampy
Copy link
Copy Markdown

dthampy commented Apr 17, 2026

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
Edit: AWS_BEARER_TOKEN_BEDROCK secret is already 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.
@pru55e11
Copy link
Copy Markdown
Contributor Author

pru55e11 commented Apr 17, 2026

Thanks for the feedback @purplecabbage -- pushed 1faad22 addressing all three points.

Restructured under api topic

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.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

🤖 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

Comment thread src/commands/console/workspace/api/add.js
Comment thread src/commands/console/workspace/api/list.js
Copy link
Copy Markdown

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

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.

Comment thread src/commands/console/workspace/api/add.js
Comment thread src/commands/console/api/list.js
@pru55e11 pru55e11 merged commit f37c3b7 into master Apr 20, 2026
11 checks passed
@pru55e11 pru55e11 deleted the feat/workspace-add-api branch April 20, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants