UNPKG

azdev-automation

Version:

Azure DevOps automation framework enables access control automation of projects, pipelines and repositories configuration in Azure DevOps Services

30 lines (29 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WorkHelper = void 0; const iazdevclient_1 = require("../common/iazdevclient"); class WorkHelper { constructor(azdevClient, logger) { this.debugLogger = logger.extend(this.constructor.name); this.azdevClient = azdevClient; } async getNodeIdentifier(projectId, type) { const debug = this.debugLogger.extend(this.getNodeIdentifier.name); const response = await this.azdevClient.get(`${projectId}/_apis/wit/classificationnodes`, iazdevclient_1.AzDevApiType.Core); const allNodes = response.value; if (!allNodes) { throw new Error("No nodes found"); } const node = allNodes.filter((i) => i.structureType === type)[0]; if (!node) { throw new Error(`Node <${type}> not found`); } const identifier = node.identifier; if (!identifier) { throw new Error(`Node <${type}> identifier not found`); } debug(`Node <${node.structureType}> identifier <${identifier}> found`); return identifier; } } exports.WorkHelper = WorkHelper;