feat(cloud-manager-client): add CloudManagerApiClient for CM Management API#1794
Draft
rpapani wants to merge 2 commits into
Draft
feat(cloud-manager-client): add CloudManagerApiClient for CM Management API#1794rpapani wants to merge 2 commits into
rpapani wants to merge 2 commits into
Conversation
…nt API Adds a read-only client for the Cloud Manager (SSG) Management API, distinct from the existing git-operations CloudManagerClient. Resolves a program source code coordinates (owner/repo/ref/type) and IMS org during onboarding. Auth is OAuth Server-to-Server (client_credentials) via IMS getServiceAccessTokenV3; requests carry Bearer + x-api-key + x-gw-ims-org-id. Reachable from SpaceCat only over the private *.private.adobe.io endpoint via MCT (SITES-41140) - CM_API_BASE selects the per-env private endpoint. Methods: getProductionPipeline, getRepository, getProgram, resolveCodeConfig. SITES-40809 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
This PR will trigger a minor release when merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
CloudManagerApiClienttospacecat-shared-cloud-manager-client— a read-only client for the Cloud Manager (SSG) Management API, distinct from the existing git-operationsCloudManagerClient(clone/push/pull/PR).It resolves an AEM CS site's source-code coordinates and IMS org during onboarding:
getProductionPipeline(programId)GET /program/{id}/pipelines{ repositoryId, branch }(CI_CD +STAGE_PROD, elsePROD; BUILD phase)getRepository(programId, repositoryId)GET /program/{id}/repository/{id}{ url, type }getProgram(programId)GET /program/{id}{ imsOrgId }resolveCodeConfig(programId){ owner, repo, type, url, ref }— matchessite.codeWhy
Onboarding an AEM CS site needs its code config (
owner/repo/ref/type), but the publish hostpublish-p{programId}-e{environmentId}.adobeaemcloud.netencodes only program/environment — not the repo. The only source of truth is the CM Management API. This client is the shared building block;spacecat-api-servicewill call it from the onboarding flow (follow-up PR) to fill the existing// TODO: Add AEM CS pattern code config resolutioninupdateCodeConfig.Part of SITES-40809 (onboard automation for code optimizations).
Auth
OAuth Server-to-Server (
grant_type=client_credentials) — the CM API client credentials are exchanged with IMS viaImsClient.getServiceAccessTokenV3()(reused, not hand-rolled). Every request carriesAuthorization: Bearer <token>,x-api-key(client id),x-gw-ims-org-id.createFrom(context)reads fromcontext.env:CM_API_CLIENT_ID,CM_API_CLIENT_SECRET,CM_API_SCOPES,CM_API_IMS_ORG_ID,CM_API_BASE,IMS_HOST.Network dependency (why this is a draft)
The CM Management API is reachable from SpaceCat only over the private
*.private.adobe.ioendpoint via MCT (SITES-41140).CM_API_BASEselects the per-env private endpoint (https://ssg-stage.private.adobe.io/apidev/stage,https://ssg.private.adobe.io/apiprod). This library change has no network dependency itself, but the end-to-end path (and the consuming service) can't be exercised in dev until the MCT CM/32route lands and the consuming Lambda sits inmct_workload_subnet_ids. Draft until that gate clears so it can be verified together.Tests
test/cloud-manager-api-client.test.js— nock-driven, covers auth headers, token exchange, each method's success + error paths, and defaulting. Package coverage remains 100% lines/branches/statements/functions.