Skip to content

Add ServiceEndpointApi integration to WebApi#671

Open
ivanduplenskikh wants to merge 4 commits into
masterfrom
users/iduplenskikh/add-serviceendpoints-api
Open

Add ServiceEndpointApi integration to WebApi#671
ivanduplenskikh wants to merge 4 commits into
masterfrom
users/iduplenskikh/add-serviceendpoints-api

Conversation

@ivanduplenskikh
Copy link
Copy Markdown
Contributor

@ivanduplenskikh ivanduplenskikh commented Jun 2, 2026

Summary

Adds the missing ServiceEndpointApi client to WebApi, restoring access to Service Endpoint operations (getServiceEndpoints, createServiceEndpoint, etc.) that have been unavailable since the v8.x client generation.

Fixes #317, Fixes #310

Background

In January 2018, the Azure DevOps server moved Service Endpoint APIs from the distributedtask area to a dedicated serviceendpoint area. Because the node-api client is auto-generated from controller metadata, the obsolete methods were excluded from TaskAgentApiBase in subsequent regenerations — effectively removing getServiceEndpoints and related methods from the npm package.

Changes

File Change
api/ServiceEndpointApi.ts New — wrapper class extending ServiceEndpointApiBase (follows the same pattern as TaskAgentApi)
api/ServiceEndpointApiBase.ts New — auto-generated base class with 40+ ServiceEndpoint methods
api/WebApi.ts Added getServiceEndpointApi() factory method (resource area 1814ab31-2f4f-4a9f-8761-f4d77dc5a5d7)

Usage

import * as azdev from "azure-devops-node-api";

const connection = new azdev.WebApi(orgUrl, authHandler);
const serviceEndpointApi = await connection.getServiceEndpointApi();

// List all service endpoints in a project
const endpoints = await serviceEndpointApi.getServiceEndpoints(projectId);

Testing

  • Verified the project compiles with no new errors (pre-existing CIXApi.ts issues are unrelated)
  • Manually tested against a live Azure DevOps organization: list endpoints, get types, get by ID/name, and full CRUD cycle (create → update → delete)

@ivanduplenskikh ivanduplenskikh requested a review from a team as a code owner June 2, 2026 13:56
@ivanduplenskikh
Copy link
Copy Markdown
Contributor Author

/azp run

1 similar comment
@ivanduplenskikh
Copy link
Copy Markdown
Contributor Author

/azp run

@manolerazvan manolerazvan self-requested a review June 2, 2026 16:16
Comment thread api/WebApi.ts Outdated
Comment thread package.json Outdated
Comment thread api/ServiceEndpointApiBase.ts
@ivanduplenskikh ivanduplenskikh force-pushed the users/iduplenskikh/add-serviceendpoints-api branch from ccf74a4 to 7f786f8 Compare June 2, 2026 16:24
- Imported ServiceEndpointApi module.
- Updated _resourceAreas type to allow undefined.
- Implemented getServiceEndpointApi method to retrieve ServiceEndpointApi instance.
- Cleaned up whitespace in the encryption key handling section.
@ivanduplenskikh ivanduplenskikh force-pushed the users/iduplenskikh/add-serviceendpoints-api branch from 7f786f8 to 486dad8 Compare June 2, 2026 16:25
@ivanduplenskikh
Copy link
Copy Markdown
Contributor Author

/azp run

Comment thread package.json Outdated
@tarunramsinghani
Copy link
Copy Markdown
Contributor

COpilot review comment. Please check if we can add l0 test cases

The PR is missing unit tests for the new getServiceEndpointApi() factory method on WebApi. Here are the test cases that should be added to test/units/tests.ts in the WebApi Units describe block:

 1. Returns a ServiceEndpointApi instance with the resolved resource area URL — mock the Location area OPTIONS discovery and resource areas GET response with resource area ID 1814ab31-2f4f-4a9f-8761-f4d77dc5a5d7, then verify serviceEndpointApi.baseUrl matches the resolved locationUrl.
 2. Falls back to server URL when resource areas are empty — simulate an on-prem scenario where getResourceAreas returns { count: 0, value: null }, and verify the returned API instance uses the default server URL as its baseUrl.
 3. Uses custom handlers when provided — pass a custom BearerCredentialHandler via the handlers parameter and verify the API instance is created successfully (i.e., the default authHandler is not used).
 4. Uses custom server URL when provided — pass a custom serverUrl and verify the resource area resolution happens against that URL rather than the WebApi's default serverUrl.

Each test should mock the full Location API flow (OPTIONS on {baseUrl}/_apis/Location for route discovery, then GET on the resolved _apis/resourceAreas route) using nock, following the same pattern as the existing VSOClient Units tests.

@ivanduplenskikh
Copy link
Copy Markdown
Contributor Author

/azp run

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

This pull request restores Service Endpoint REST capabilities in azure-devops-node-api by introducing a generated ServiceEndpointApiBase, a thin ServiceEndpointApi wrapper, and wiring a new getServiceEndpointApi() factory into WebApi (including unit coverage for resource-area URL resolution).

Changes:

  • Added ServiceEndpointApiBase (generated) and ServiceEndpointApi wrapper to expose Service Endpoint operations (e.g., getServiceEndpoints, CRUD).
  • Extended WebApi with getServiceEndpointApi() that resolves the serviceendpoint resource area (1814ab31-2f4f-4a9f-8761-f4d77dc5a5d7).
  • Added unit tests validating resource-area resolution, handler override behavior, and on-prem fallback behavior.

Reviewed changes

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

Show a summary per file
File Description
api/WebApi.ts Adds getServiceEndpointApi() factory and imports the new API module.
api/ServiceEndpointApi.ts Introduces the public wrapper class/interface for consumers.
api/ServiceEndpointApiBase.ts Adds the generated base implementation with Service Endpoint methods.
test/units/tests.ts Adds unit tests for getServiceEndpointApi() URL/handler behavior.
package.json Bumps package version to 16.0.0.
package-lock.json Aligns lockfile version metadata with 16.0.0.
test/package-lock.json Aligns test lockfile metadata with 16.0.0.
Files not reviewed (1)
  • test/package-lock.json: Language not supported

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

Comment thread api/WebApi.ts
Comment thread api/ServiceEndpointApiBase.ts
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.

getServiceEndpoints missing in 8.*.* Add service endpoint api

4 participants