powerplatform-mcp
Version:
PowerPlatform Model Context Protocol server
66 lines (65 loc) • 2 kB
JavaScript
/**
* ServiceEndpointService
*
* Read-only service for Dataverse service endpoints
* (Service Bus, webhooks, Event Hub, Event Grid).
*/
const CONTRACT_NAMES = {
1: 'One-Way',
2: 'Queue',
3: 'REST',
4: 'Two-Way',
7: 'EventHub',
8: 'Webhook',
9: 'EventGrid',
};
const CONNECTION_MODE_NAMES = {
1: 'Normal',
2: 'Federated',
};
const MESSAGE_FORMAT_NAMES = {
1: 'BinaryXML',
2: 'Json',
3: 'TextXML',
};
const AUTH_TYPE_NAMES = {
1: 'ACS',
2: 'SASKey',
3: 'SASToken',
4: 'WebhookKey',
5: 'HttpHeader',
6: 'HttpQueryString',
7: 'ConnectionString',
8: 'AccessKeyAuth',
9: 'ManagedIdentity',
};
export class ServiceEndpointService {
client;
constructor(client) {
this.client = client;
}
/**
* Get all service endpoints in the environment
*/
async getServiceEndpoints(maxRecords = 100) {
const response = await this.client.get(`api/data/v9.2/serviceendpoints?$select=serviceendpointid,name,connectionmode,contract,messageformat,authtype,ismanaged,modifiedon&$orderby=name&$top=${maxRecords}`);
const endpoints = response.value.map((ep) => ({
serviceendpointid: ep.serviceendpointid,
name: ep.name,
contract: ep.contract,
contractName: CONTRACT_NAMES[ep.contract] ?? `Unknown (${ep.contract})`,
connectionMode: ep.connectionmode,
connectionModeName: CONNECTION_MODE_NAMES[ep.connectionmode] ?? `Unknown (${ep.connectionmode})`,
messageFormat: ep.messageformat,
messageFormatName: MESSAGE_FORMAT_NAMES[ep.messageformat] ?? `Unknown (${ep.messageformat})`,
authType: ep.authtype,
authTypeName: AUTH_TYPE_NAMES[ep.authtype] ?? `Unknown (${ep.authtype})`,
isManaged: ep.ismanaged,
modifiedOn: ep.modifiedon,
}));
return {
totalCount: endpoints.length,
endpoints,
};
}
}