50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
|
|
import * as interfaces from '../ts_interfaces/index.js';
|
||
|
|
import type { DcRouterApiClient } from './classes.dcrouterapiclient.js';
|
||
|
|
|
||
|
|
export class WorkHosterManager {
|
||
|
|
constructor(private clientRef: DcRouterApiClient) {}
|
||
|
|
|
||
|
|
public async getCapabilities(): Promise<interfaces.data.IGatewayCapabilities> {
|
||
|
|
const response = await this.clientRef.request<interfaces.requests.IReq_GetGatewayCapabilities>(
|
||
|
|
'getGatewayCapabilities',
|
||
|
|
this.clientRef.buildRequestPayload() as any,
|
||
|
|
);
|
||
|
|
return response.capabilities;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async getDomains(): Promise<interfaces.data.IWorkHosterDomain[]> {
|
||
|
|
const response = await this.clientRef.request<interfaces.requests.IReq_GetWorkHosterDomains>(
|
||
|
|
'getWorkHosterDomains',
|
||
|
|
this.clientRef.buildRequestPayload() as any,
|
||
|
|
);
|
||
|
|
return response.domains;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async syncRoute(options: {
|
||
|
|
ownership: interfaces.data.IWorkAppRouteOwnership;
|
||
|
|
route: interfaces.data.IDcRouterRouteConfig;
|
||
|
|
enabled?: boolean;
|
||
|
|
}): Promise<interfaces.data.IWorkAppRouteSyncResult> {
|
||
|
|
return this.clientRef.request<interfaces.requests.IReq_SyncWorkAppRoute>(
|
||
|
|
'syncWorkAppRoute',
|
||
|
|
this.clientRef.buildRequestPayload({
|
||
|
|
ownership: options.ownership,
|
||
|
|
route: options.route,
|
||
|
|
enabled: options.enabled,
|
||
|
|
}) as any,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public async deleteRoute(
|
||
|
|
ownership: interfaces.data.IWorkAppRouteOwnership,
|
||
|
|
): Promise<interfaces.data.IWorkAppRouteSyncResult> {
|
||
|
|
return this.clientRef.request<interfaces.requests.IReq_SyncWorkAppRoute>(
|
||
|
|
'syncWorkAppRoute',
|
||
|
|
this.clientRef.buildRequestPayload({
|
||
|
|
ownership,
|
||
|
|
delete: true,
|
||
|
|
}) as any,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|