@serve.zone/dcrouter-apiclient 32.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_ts_apiclient/classes.apitoken.d.ts +41 -0
- package/dist_ts_apiclient/classes.apitoken.js +115 -0
- package/dist_ts_apiclient/classes.certificate.d.ts +57 -0
- package/dist_ts_apiclient/classes.certificate.js +69 -0
- package/dist_ts_apiclient/classes.config.d.ts +7 -0
- package/dist_ts_apiclient/classes.config.js +11 -0
- package/dist_ts_apiclient/classes.dcrouterapiclient.d.ts +54 -0
- package/dist_ts_apiclient/classes.dcrouterapiclient.js +97 -0
- package/dist_ts_apiclient/classes.email.d.ts +30 -0
- package/dist_ts_apiclient/classes.email.js +52 -0
- package/dist_ts_apiclient/classes.gatewayclient.d.ts +28 -0
- package/dist_ts_apiclient/classes.gatewayclient.js +52 -0
- package/dist_ts_apiclient/classes.logs.d.ts +28 -0
- package/dist_ts_apiclient/classes.logs.js +69 -0
- package/dist_ts_apiclient/classes.radius.d.ts +59 -0
- package/dist_ts_apiclient/classes.radius.js +95 -0
- package/dist_ts_apiclient/classes.remoteingress.d.ts +66 -0
- package/dist_ts_apiclient/classes.remoteingress.js +164 -0
- package/dist_ts_apiclient/classes.route.d.ts +39 -0
- package/dist_ts_apiclient/classes.route.js +125 -0
- package/dist_ts_apiclient/classes.stats.d.ts +47 -0
- package/dist_ts_apiclient/classes.stats.js +38 -0
- package/dist_ts_apiclient/classes.testing.d.ts +65 -0
- package/dist_ts_apiclient/classes.testing.js +120 -0
- package/dist_ts_apiclient/index.d.ts +12 -0
- package/dist_ts_apiclient/index.js +16 -0
- package/dist_ts_apiclient/plugins.d.ts +4 -0
- package/dist_ts_apiclient/plugins.js +6 -0
- package/dist_ts_interfaces/data/acme-config.d.ts +23 -0
- package/dist_ts_interfaces/data/acme-config.js +2 -0
- package/dist_ts_interfaces/data/auth.d.ts +8 -0
- package/dist_ts_interfaces/data/auth.js +2 -0
- package/dist_ts_interfaces/data/config-events.d.ts +34 -0
- package/dist_ts_interfaces/data/config-events.js +8 -0
- package/dist_ts_interfaces/data/dns-authority.d.ts +98 -0
- package/dist_ts_interfaces/data/dns-authority.js +26 -0
- package/dist_ts_interfaces/data/dns-provider.d.ts +136 -0
- package/dist_ts_interfaces/data/dns-provider.js +41 -0
- package/dist_ts_interfaces/data/dns-record.d.ts +48 -0
- package/dist_ts_interfaces/data/dns-record.js +2 -0
- package/dist_ts_interfaces/data/domain.d.ts +35 -0
- package/dist_ts_interfaces/data/domain.js +2 -0
- package/dist_ts_interfaces/data/email-domain.d.ts +177 -0
- package/dist_ts_interfaces/data/email-domain.js +2 -0
- package/dist_ts_interfaces/data/email-settings.d.ts +68 -0
- package/dist_ts_interfaces/data/email-settings.js +2 -0
- package/dist_ts_interfaces/data/index.d.ts +18 -0
- package/dist_ts_interfaces/data/index.js +19 -0
- package/dist_ts_interfaces/data/remoteingress.d.ts +181 -0
- package/dist_ts_interfaces/data/remoteingress.js +15 -0
- package/dist_ts_interfaces/data/route-management.d.ts +270 -0
- package/dist_ts_interfaces/data/route-management.js +130 -0
- package/dist_ts_interfaces/data/security-policy.d.ts +32 -0
- package/dist_ts_interfaces/data/security-policy.js +2 -0
- package/dist_ts_interfaces/data/smtp-account.d.ts +50 -0
- package/dist_ts_interfaces/data/smtp-account.js +9 -0
- package/dist_ts_interfaces/data/stats.d.ts +283 -0
- package/dist_ts_interfaces/data/stats.js +2 -0
- package/dist_ts_interfaces/data/target-profile.d.ts +30 -0
- package/dist_ts_interfaces/data/target-profile.js +2 -0
- package/dist_ts_interfaces/data/testing.d.ts +191 -0
- package/dist_ts_interfaces/data/testing.js +20 -0
- package/dist_ts_interfaces/data/vpn.d.ts +65 -0
- package/dist_ts_interfaces/data/vpn.js +2 -0
- package/dist_ts_interfaces/data/workhoster.d.ts +63 -0
- package/dist_ts_interfaces/data/workhoster.js +2 -0
- package/dist_ts_interfaces/index.d.ts +5 -0
- package/dist_ts_interfaces/index.js +8 -0
- package/dist_ts_interfaces/plugins.d.ts +2 -0
- package/dist_ts_interfaces/plugins.js +4 -0
- package/dist_ts_interfaces/requests/acme-config.d.ts +42 -0
- package/dist_ts_interfaces/requests/acme-config.js +2 -0
- package/dist_ts_interfaces/requests/admin.d.ts +69 -0
- package/dist_ts_interfaces/requests/admin.js +3 -0
- package/dist_ts_interfaces/requests/api-tokens.d.ts +85 -0
- package/dist_ts_interfaces/requests/api-tokens.js +2 -0
- package/dist_ts_interfaces/requests/certificate.d.ts +87 -0
- package/dist_ts_interfaces/requests/certificate.js +5 -0
- package/dist_ts_interfaces/requests/combined.stats.d.ts +29 -0
- package/dist_ts_interfaces/requests/combined.stats.js +2 -0
- package/dist_ts_interfaces/requests/config-events.d.ts +35 -0
- package/dist_ts_interfaces/requests/config-events.js +4 -0
- package/dist_ts_interfaces/requests/config.d.ts +93 -0
- package/dist_ts_interfaces/requests/config.js +3 -0
- package/dist_ts_interfaces/requests/dns-authority.d.ts +80 -0
- package/dist_ts_interfaces/requests/dns-authority.js +3 -0
- package/dist_ts_interfaces/requests/dns-providers.d.ts +117 -0
- package/dist_ts_interfaces/requests/dns-providers.js +2 -0
- package/dist_ts_interfaces/requests/dns-records.d.ts +89 -0
- package/dist_ts_interfaces/requests/dns-records.js +2 -0
- package/dist_ts_interfaces/requests/domains.d.ts +142 -0
- package/dist_ts_interfaces/requests/domains.js +2 -0
- package/dist_ts_interfaces/requests/email-domains.d.ts +154 -0
- package/dist_ts_interfaces/requests/email-domains.js +2 -0
- package/dist_ts_interfaces/requests/email-ops.d.ts +211 -0
- package/dist_ts_interfaces/requests/email-ops.js +3 -0
- package/dist_ts_interfaces/requests/email-settings.d.ts +26 -0
- package/dist_ts_interfaces/requests/email-settings.js +2 -0
- package/dist_ts_interfaces/requests/index.d.ts +29 -0
- package/dist_ts_interfaces/requests/index.js +30 -0
- package/dist_ts_interfaces/requests/logs.d.ts +43 -0
- package/dist_ts_interfaces/requests/logs.js +4 -0
- package/dist_ts_interfaces/requests/network-targets.d.ts +102 -0
- package/dist_ts_interfaces/requests/network-targets.js +2 -0
- package/dist_ts_interfaces/requests/radius.d.ts +280 -0
- package/dist_ts_interfaces/requests/radius.js +3 -0
- package/dist_ts_interfaces/requests/realtime.d.ts +38 -0
- package/dist_ts_interfaces/requests/realtime.js +12 -0
- package/dist_ts_interfaces/requests/remoteingress.d.ts +162 -0
- package/dist_ts_interfaces/requests/remoteingress.js +3 -0
- package/dist_ts_interfaces/requests/route-management.d.ts +147 -0
- package/dist_ts_interfaces/requests/route-management.js +2 -0
- package/dist_ts_interfaces/requests/security-policy.d.ts +105 -0
- package/dist_ts_interfaces/requests/security-policy.js +2 -0
- package/dist_ts_interfaces/requests/smtp-accounts.d.ts +125 -0
- package/dist_ts_interfaces/requests/smtp-accounts.js +2 -0
- package/dist_ts_interfaces/requests/source-profiles.d.ts +102 -0
- package/dist_ts_interfaces/requests/source-profiles.js +2 -0
- package/dist_ts_interfaces/requests/stats.d.ts +196 -0
- package/dist_ts_interfaces/requests/stats.js +4 -0
- package/dist_ts_interfaces/requests/target-profiles.d.ts +105 -0
- package/dist_ts_interfaces/requests/target-profiles.js +2 -0
- package/dist_ts_interfaces/requests/testing.d.ts +169 -0
- package/dist_ts_interfaces/requests/testing.js +2 -0
- package/dist_ts_interfaces/requests/users.d.ts +53 -0
- package/dist_ts_interfaces/requests/users.js +3 -0
- package/dist_ts_interfaces/requests/vpn.d.ts +188 -0
- package/dist_ts_interfaces/requests/vpn.js +3 -0
- package/dist_ts_interfaces/requests/workhoster.d.ts +79 -0
- package/dist_ts_interfaces/requests/workhoster.js +2 -0
- package/license +21 -0
- package/package.json +67 -0
- package/readme.md +218 -0
- package/ts_apiclient/classes.apitoken.ts +157 -0
- package/ts_apiclient/classes.certificate.ts +124 -0
- package/ts_apiclient/classes.config.ts +17 -0
- package/ts_apiclient/classes.dcrouterapiclient.ts +138 -0
- package/ts_apiclient/classes.email.ts +77 -0
- package/ts_apiclient/classes.gatewayclient.ts +110 -0
- package/ts_apiclient/classes.logs.ts +91 -0
- package/ts_apiclient/classes.radius.ts +180 -0
- package/ts_apiclient/classes.remoteingress.ts +217 -0
- package/ts_apiclient/classes.route.ts +166 -0
- package/ts_apiclient/classes.stats.ts +111 -0
- package/ts_apiclient/classes.testing.ts +152 -0
- package/ts_apiclient/index.ts +17 -0
- package/ts_apiclient/plugins.ts +10 -0
- package/ts_apiclient/readme.md +218 -0
- package/ts_interfaces/data/acme-config.ts +23 -0
- package/ts_interfaces/data/auth.ts +8 -0
- package/ts_interfaces/data/config-events.ts +38 -0
- package/ts_interfaces/data/dns-authority.ts +106 -0
- package/ts_interfaces/data/dns-provider.ts +174 -0
- package/ts_interfaces/data/dns-record.ts +50 -0
- package/ts_interfaces/data/domain.ts +36 -0
- package/ts_interfaces/data/email-domain.ts +206 -0
- package/ts_interfaces/data/email-settings.ts +75 -0
- package/ts_interfaces/data/index.ts +18 -0
- package/ts_interfaces/data/remoteingress.ts +204 -0
- package/ts_interfaces/data/route-management.ts +436 -0
- package/ts_interfaces/data/security-policy.ts +37 -0
- package/ts_interfaces/data/smtp-account.ts +63 -0
- package/ts_interfaces/data/stats.ts +305 -0
- package/ts_interfaces/data/target-profile.ts +31 -0
- package/ts_interfaces/data/testing.ts +184 -0
- package/ts_interfaces/data/vpn.ts +68 -0
- package/ts_interfaces/data/workhoster.ts +72 -0
- package/ts_interfaces/index.ts +9 -0
- package/ts_interfaces/plugins.ts +6 -0
- package/ts_interfaces/readme.md +194 -0
- package/ts_interfaces/requests/acme-config.ts +54 -0
- package/ts_interfaces/requests/admin.ts +96 -0
- package/ts_interfaces/requests/api-tokens.ts +109 -0
- package/ts_interfaces/requests/certificate.ts +106 -0
- package/ts_interfaces/requests/combined.stats.ts +30 -0
- package/ts_interfaces/requests/config-events.ts +45 -0
- package/ts_interfaces/requests/config.ts +94 -0
- package/ts_interfaces/requests/dns-authority.ts +104 -0
- package/ts_interfaces/requests/dns-providers.ts +154 -0
- package/ts_interfaces/requests/dns-records.ts +113 -0
- package/ts_interfaces/requests/domains.ts +178 -0
- package/ts_interfaces/requests/email-domains.ts +193 -0
- package/ts_interfaces/requests/email-ops.ts +266 -0
- package/ts_interfaces/requests/email-settings.ts +34 -0
- package/ts_interfaces/requests/index.ts +29 -0
- package/ts_interfaces/requests/logs.ts +58 -0
- package/ts_interfaces/requests/network-targets.ts +127 -0
- package/ts_interfaces/requests/radius.ts +341 -0
- package/ts_interfaces/requests/realtime.ts +59 -0
- package/ts_interfaces/requests/remoteingress.ts +202 -0
- package/ts_interfaces/requests/route-management.ts +194 -0
- package/ts_interfaces/requests/security-policy.ts +144 -0
- package/ts_interfaces/requests/smtp-accounts.ts +163 -0
- package/ts_interfaces/requests/source-profiles.ts +127 -0
- package/ts_interfaces/requests/stats.ts +207 -0
- package/ts_interfaces/requests/target-profiles.ts +130 -0
- package/ts_interfaces/requests/testing.ts +186 -0
- package/ts_interfaces/requests/users.ts +66 -0
- package/ts_interfaces/requests/vpn.ts +238 -0
- package/ts_interfaces/requests/workhoster.ts +100 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as interfaces from '../ts_interfaces/index.js';
|
|
2
|
+
import type { DcRouterApiClient } from './classes.dcrouterapiclient.js';
|
|
3
|
+
|
|
4
|
+
export class Email {
|
|
5
|
+
private clientRef: DcRouterApiClient;
|
|
6
|
+
|
|
7
|
+
// Data from IEmail
|
|
8
|
+
public id: string;
|
|
9
|
+
public direction: interfaces.requests.TEmailDirection;
|
|
10
|
+
public status: interfaces.requests.TEmailStatus;
|
|
11
|
+
public from: string;
|
|
12
|
+
public to: string;
|
|
13
|
+
public subject: string;
|
|
14
|
+
public timestamp: string;
|
|
15
|
+
public messageId: string;
|
|
16
|
+
public size: string;
|
|
17
|
+
|
|
18
|
+
constructor(clientRef: DcRouterApiClient, data: interfaces.requests.IEmail) {
|
|
19
|
+
this.clientRef = clientRef;
|
|
20
|
+
this.id = data.id;
|
|
21
|
+
this.direction = data.direction;
|
|
22
|
+
this.status = data.status;
|
|
23
|
+
this.from = data.from;
|
|
24
|
+
this.to = data.to;
|
|
25
|
+
this.subject = data.subject;
|
|
26
|
+
this.timestamp = data.timestamp;
|
|
27
|
+
this.messageId = data.messageId;
|
|
28
|
+
this.size = data.size;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public async getDetail(): Promise<interfaces.requests.IEmailDetail | null> {
|
|
32
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_GetEmailDetail>(
|
|
33
|
+
'getEmailDetail',
|
|
34
|
+
this.clientRef.buildRequestPayload({ emailId: this.id }) as any,
|
|
35
|
+
);
|
|
36
|
+
return response.email;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public async resend(): Promise<{ success: boolean; newQueueId?: string }> {
|
|
40
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_ResendEmail>(
|
|
41
|
+
'resendEmail',
|
|
42
|
+
this.clientRef.buildRequestPayload({ emailId: this.id }) as any,
|
|
43
|
+
);
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class EmailManager {
|
|
49
|
+
private clientRef: DcRouterApiClient;
|
|
50
|
+
|
|
51
|
+
constructor(clientRef: DcRouterApiClient) {
|
|
52
|
+
this.clientRef = clientRef;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async list(): Promise<Email[]> {
|
|
56
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_GetAllEmails>(
|
|
57
|
+
'getAllEmails',
|
|
58
|
+
this.clientRef.buildRequestPayload() as any,
|
|
59
|
+
);
|
|
60
|
+
return response.emails.map((e) => new Email(this.clientRef, e));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public async getDetail(emailId: string): Promise<interfaces.requests.IEmailDetail | null> {
|
|
64
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_GetEmailDetail>(
|
|
65
|
+
'getEmailDetail',
|
|
66
|
+
this.clientRef.buildRequestPayload({ emailId }) as any,
|
|
67
|
+
);
|
|
68
|
+
return response.email;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public async resend(emailId: string): Promise<{ success: boolean; newQueueId?: string }> {
|
|
72
|
+
return this.clientRef.request<interfaces.requests.IReq_ResendEmail>(
|
|
73
|
+
'resendEmail',
|
|
74
|
+
this.clientRef.buildRequestPayload({ emailId }) as any,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type * as servezoneInterfaces from '@serve.zone/interfaces';
|
|
2
|
+
import type { DcRouterApiClient } from './classes.dcrouterapiclient.js';
|
|
3
|
+
|
|
4
|
+
export class GatewayClientApi {
|
|
5
|
+
constructor(private clientRef: DcRouterApiClient) {}
|
|
6
|
+
|
|
7
|
+
public async getCapabilities(): Promise<servezoneInterfaces.data.IGatewayCapabilities> {
|
|
8
|
+
const response = await this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_GetGatewayCapabilities>(
|
|
9
|
+
'getGatewayCapabilities',
|
|
10
|
+
this.clientRef.buildRequestPayload() as any,
|
|
11
|
+
);
|
|
12
|
+
return response.capabilities;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async getGatewayClientContext(): Promise<servezoneInterfaces.data.IGatewayClientContext> {
|
|
16
|
+
const response = await this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_GetGatewayClientContext>(
|
|
17
|
+
'getGatewayClientContext',
|
|
18
|
+
this.clientRef.buildRequestPayload() as any,
|
|
19
|
+
);
|
|
20
|
+
return response.context;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async provisionCredential(options: {
|
|
24
|
+
provisioning: servezoneInterfaces.data.IGatewayClientProvisioningSpec;
|
|
25
|
+
credentialName?: string;
|
|
26
|
+
expiresInDays?: number | null;
|
|
27
|
+
}): Promise<servezoneInterfaces.requests.gateway.IReq_ProvisionGatewayClientCredential['response']> {
|
|
28
|
+
return await this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_ProvisionGatewayClientCredential>(
|
|
29
|
+
'provisionGatewayClientCredential',
|
|
30
|
+
this.clientRef.buildRequestPayload(options) as any,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public async finalizeCredential(
|
|
35
|
+
credential: Pick<servezoneInterfaces.data.IGatewayClientCredential, 'tokenId' | 'tokenValue'>,
|
|
36
|
+
): Promise<servezoneInterfaces.requests.gateway.IReq_FinalizeGatewayClientCredential['response']> {
|
|
37
|
+
return await this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_FinalizeGatewayClientCredential>(
|
|
38
|
+
'finalizeGatewayClientCredential',
|
|
39
|
+
{ apiToken: credential.tokenValue, tokenId: credential.tokenId },
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public async getMailOverview(
|
|
44
|
+
limit?: number,
|
|
45
|
+
): Promise<servezoneInterfaces.requests.gateway.IReq_GetGatewayClientMailOverview['response']> {
|
|
46
|
+
return await this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_GetGatewayClientMailOverview>(
|
|
47
|
+
'getGatewayClientMailOverview',
|
|
48
|
+
this.clientRef.buildRequestPayload({ limit }) as any,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public async getDomains(): Promise<servezoneInterfaces.data.IGatewayDomain[]> {
|
|
53
|
+
const response = await this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_GetGatewayClientDomains>(
|
|
54
|
+
'getGatewayClientDomains',
|
|
55
|
+
this.clientRef.buildRequestPayload() as any,
|
|
56
|
+
);
|
|
57
|
+
return response.domains;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public async getDnsRecords(): Promise<servezoneInterfaces.data.IGatewayDnsRecord[]> {
|
|
61
|
+
const response = await this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_GetGatewayClientDnsRecords>(
|
|
62
|
+
'getGatewayClientDnsRecords',
|
|
63
|
+
this.clientRef.buildRequestPayload() as any,
|
|
64
|
+
);
|
|
65
|
+
return response.records;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public async getRoutes(): Promise<servezoneInterfaces.data.IGatewayClientRoute[]> {
|
|
69
|
+
const response = await this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_GetGatewayClientRoutes>(
|
|
70
|
+
'getGatewayClientRoutes',
|
|
71
|
+
this.clientRef.buildRequestPayload() as any,
|
|
72
|
+
);
|
|
73
|
+
return response.routes;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public async syncRoute(options: {
|
|
77
|
+
ownership: servezoneInterfaces.data.IGatewayClientOwnership;
|
|
78
|
+
route: servezoneInterfaces.data.IGatewayRouteConfig;
|
|
79
|
+
enabled?: boolean;
|
|
80
|
+
dnsMode?: servezoneInterfaces.data.TGatewayRouteDnsMode;
|
|
81
|
+
sourceProfileRef?: string;
|
|
82
|
+
}): Promise<servezoneInterfaces.data.IGatewayRouteSyncResult> {
|
|
83
|
+
return this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_SyncGatewayClientRoute>(
|
|
84
|
+
'syncGatewayClientRoute',
|
|
85
|
+
this.clientRef.buildRequestPayload({
|
|
86
|
+
ownership: options.ownership,
|
|
87
|
+
route: options.route,
|
|
88
|
+
enabled: options.enabled,
|
|
89
|
+
dnsMode: options.dnsMode,
|
|
90
|
+
sourceProfileRef: options.sourceProfileRef,
|
|
91
|
+
}) as any,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public async deleteRoute(
|
|
96
|
+
ownership: servezoneInterfaces.data.IGatewayClientOwnership,
|
|
97
|
+
options: {
|
|
98
|
+
dnsMode?: servezoneInterfaces.data.TGatewayRouteDnsMode;
|
|
99
|
+
} = {},
|
|
100
|
+
): Promise<servezoneInterfaces.data.IGatewayRouteSyncResult> {
|
|
101
|
+
return this.clientRef.request<servezoneInterfaces.requests.gateway.IReq_SyncGatewayClientRoute>(
|
|
102
|
+
'syncGatewayClientRoute',
|
|
103
|
+
this.clientRef.buildRequestPayload({
|
|
104
|
+
ownership,
|
|
105
|
+
delete: true,
|
|
106
|
+
dnsMode: options.dnsMode,
|
|
107
|
+
}) as any,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as interfaces from '../ts_interfaces/index.js';
|
|
2
|
+
import type { DcRouterApiClient } from './classes.dcrouterapiclient.js';
|
|
3
|
+
import * as plugins from './plugins.js';
|
|
4
|
+
|
|
5
|
+
export class LogManager {
|
|
6
|
+
private clientRef: DcRouterApiClient;
|
|
7
|
+
private connections = new Set<Promise<plugins.typedsocket.TypedSocket>>();
|
|
8
|
+
private stopped = false;
|
|
9
|
+
private generation = 0;
|
|
10
|
+
|
|
11
|
+
constructor(clientRef: DcRouterApiClient) {
|
|
12
|
+
this.clientRef = clientRef;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async getRecent(options?: {
|
|
16
|
+
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
17
|
+
category?: 'smtp' | 'dns' | 'security' | 'system' | 'email';
|
|
18
|
+
limit?: number;
|
|
19
|
+
offset?: number;
|
|
20
|
+
search?: string;
|
|
21
|
+
timeRange?: string;
|
|
22
|
+
}): Promise<interfaces.requests.IReq_GetRecentLogs['response']> {
|
|
23
|
+
return this.clientRef.request<interfaces.requests.IReq_GetRecentLogs>(
|
|
24
|
+
'getRecentLogs',
|
|
25
|
+
this.clientRef.buildRequestPayload(options || {}) as any,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public async getStream(options?: {
|
|
30
|
+
follow?: boolean;
|
|
31
|
+
filters?: {
|
|
32
|
+
level?: string[];
|
|
33
|
+
category?: string[];
|
|
34
|
+
};
|
|
35
|
+
}): Promise<interfaces.requests.IReq_GetLogStream['response']> {
|
|
36
|
+
if (this.stopped) throw new Error('Log client is stopped');
|
|
37
|
+
const generation = this.generation;
|
|
38
|
+
// A stream owns one connection; terminal cleanup also releases its socket.
|
|
39
|
+
const connection = plugins.typedsocket.TypedSocket.createClient(
|
|
40
|
+
new plugins.typedrequest.TypedRouter(),
|
|
41
|
+
this.clientRef.baseUrl,
|
|
42
|
+
{ autoReconnect: false },
|
|
43
|
+
);
|
|
44
|
+
this.connections.add(connection);
|
|
45
|
+
let socket: plugins.typedsocket.TypedSocket | undefined;
|
|
46
|
+
const release = async () => {
|
|
47
|
+
try {
|
|
48
|
+
if (socket) await socket.stop();
|
|
49
|
+
} finally {
|
|
50
|
+
this.connections.delete(connection);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
socket = await connection;
|
|
55
|
+
if (this.stopped || generation !== this.generation) throw new Error('Log client was closed');
|
|
56
|
+
const response = await socket.createTypedRequest<interfaces.requests.IReq_GetLogStream>(
|
|
57
|
+
'getLogStream',
|
|
58
|
+
).fire(this.clientRef.buildRequestPayload(options || {}));
|
|
59
|
+
void response.logStream.closed.then(release).catch((error) => {
|
|
60
|
+
console.error('Log stream connection cleanup failed', error);
|
|
61
|
+
});
|
|
62
|
+
return response;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
await release();
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Abort outstanding streams, including requests still establishing their connection. */
|
|
70
|
+
public async stop(): Promise<void> {
|
|
71
|
+
this.stopped = true;
|
|
72
|
+
await this.close();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Close current connections while allowing a later authenticated session. */
|
|
76
|
+
public async close(): Promise<void> {
|
|
77
|
+
this.generation++;
|
|
78
|
+
const results = await Promise.allSettled(Array.from(this.connections, async (connection) => {
|
|
79
|
+
try {
|
|
80
|
+
const socket = await connection;
|
|
81
|
+
await socket.stop();
|
|
82
|
+
} finally {
|
|
83
|
+
this.connections.delete(connection);
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
const failures = results.filter((result) => result.status === 'rejected');
|
|
87
|
+
if (failures.length) {
|
|
88
|
+
throw new AggregateError(failures.map((result) => result.reason), 'Log client cleanup failed');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import * as interfaces from '../ts_interfaces/index.js';
|
|
2
|
+
import type { DcRouterApiClient } from './classes.dcrouterapiclient.js';
|
|
3
|
+
|
|
4
|
+
// =====================
|
|
5
|
+
// Sub-managers
|
|
6
|
+
// =====================
|
|
7
|
+
|
|
8
|
+
export class RadiusClientManager {
|
|
9
|
+
private clientRef: DcRouterApiClient;
|
|
10
|
+
|
|
11
|
+
constructor(clientRef: DcRouterApiClient) {
|
|
12
|
+
this.clientRef = clientRef;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async list(): Promise<Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
ipRange: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
}>> {
|
|
21
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_GetRadiusClients>(
|
|
22
|
+
'getRadiusClients',
|
|
23
|
+
this.clientRef.buildRequestPayload() as any,
|
|
24
|
+
);
|
|
25
|
+
return response.clients;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public async set(client: {
|
|
29
|
+
name: string;
|
|
30
|
+
ipRange: string;
|
|
31
|
+
secret: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
}): Promise<void> {
|
|
35
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_SetRadiusClient>(
|
|
36
|
+
'setRadiusClient',
|
|
37
|
+
this.clientRef.buildRequestPayload({ client }) as any,
|
|
38
|
+
);
|
|
39
|
+
if (!response.success) {
|
|
40
|
+
throw new Error(response.message || 'Failed to set RADIUS client');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public async remove(name: string): Promise<void> {
|
|
45
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_RemoveRadiusClient>(
|
|
46
|
+
'removeRadiusClient',
|
|
47
|
+
this.clientRef.buildRequestPayload({ name }) as any,
|
|
48
|
+
);
|
|
49
|
+
if (!response.success) {
|
|
50
|
+
throw new Error(response.message || 'Failed to remove RADIUS client');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class RadiusVlanManager {
|
|
56
|
+
private clientRef: DcRouterApiClient;
|
|
57
|
+
|
|
58
|
+
constructor(clientRef: DcRouterApiClient) {
|
|
59
|
+
this.clientRef = clientRef;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public async list(): Promise<interfaces.requests.IReq_GetVlanMappings['response']> {
|
|
63
|
+
return this.clientRef.request<interfaces.requests.IReq_GetVlanMappings>(
|
|
64
|
+
'getVlanMappings',
|
|
65
|
+
this.clientRef.buildRequestPayload() as any,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public async set(mapping: {
|
|
70
|
+
mac: string;
|
|
71
|
+
vlan: number;
|
|
72
|
+
description?: string;
|
|
73
|
+
enabled: boolean;
|
|
74
|
+
}): Promise<void> {
|
|
75
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_SetVlanMapping>(
|
|
76
|
+
'setVlanMapping',
|
|
77
|
+
this.clientRef.buildRequestPayload({ mapping }) as any,
|
|
78
|
+
);
|
|
79
|
+
if (!response.success) {
|
|
80
|
+
throw new Error(response.message || 'Failed to set VLAN mapping');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public async remove(mac: string): Promise<void> {
|
|
85
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_RemoveVlanMapping>(
|
|
86
|
+
'removeVlanMapping',
|
|
87
|
+
this.clientRef.buildRequestPayload({ mac }) as any,
|
|
88
|
+
);
|
|
89
|
+
if (!response.success) {
|
|
90
|
+
throw new Error(response.message || 'Failed to remove VLAN mapping');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public async updateConfig(options: {
|
|
95
|
+
defaultVlan?: number;
|
|
96
|
+
allowUnknownMacs?: boolean;
|
|
97
|
+
}): Promise<{ defaultVlan: number; allowUnknownMacs: boolean }> {
|
|
98
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_UpdateVlanConfig>(
|
|
99
|
+
'updateVlanConfig',
|
|
100
|
+
this.clientRef.buildRequestPayload(options) as any,
|
|
101
|
+
);
|
|
102
|
+
if (!response.success) {
|
|
103
|
+
throw new Error('Failed to update VLAN config');
|
|
104
|
+
}
|
|
105
|
+
return response.config;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public async testAssignment(mac: string): Promise<interfaces.requests.IReq_TestVlanAssignment['response']> {
|
|
109
|
+
return this.clientRef.request<interfaces.requests.IReq_TestVlanAssignment>(
|
|
110
|
+
'testVlanAssignment',
|
|
111
|
+
this.clientRef.buildRequestPayload({ mac }) as any,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export class RadiusSessionManager {
|
|
117
|
+
private clientRef: DcRouterApiClient;
|
|
118
|
+
|
|
119
|
+
constructor(clientRef: DcRouterApiClient) {
|
|
120
|
+
this.clientRef = clientRef;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public async list(filter?: {
|
|
124
|
+
username?: string;
|
|
125
|
+
nasIpAddress?: string;
|
|
126
|
+
vlanId?: number;
|
|
127
|
+
}): Promise<interfaces.requests.IReq_GetRadiusSessions['response']> {
|
|
128
|
+
return this.clientRef.request<interfaces.requests.IReq_GetRadiusSessions>(
|
|
129
|
+
'getRadiusSessions',
|
|
130
|
+
this.clientRef.buildRequestPayload({ filter }) as any,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public async disconnect(sessionId: string, reason?: string): Promise<void> {
|
|
135
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_DisconnectRadiusSession>(
|
|
136
|
+
'disconnectRadiusSession',
|
|
137
|
+
this.clientRef.buildRequestPayload({ sessionId, reason }) as any,
|
|
138
|
+
);
|
|
139
|
+
if (!response.success) {
|
|
140
|
+
throw new Error(response.message || 'Failed to disconnect session');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// =====================
|
|
146
|
+
// Main RADIUS Manager
|
|
147
|
+
// =====================
|
|
148
|
+
|
|
149
|
+
export class RadiusManager {
|
|
150
|
+
private clientRef: DcRouterApiClient;
|
|
151
|
+
|
|
152
|
+
public clients: RadiusClientManager;
|
|
153
|
+
public vlans: RadiusVlanManager;
|
|
154
|
+
public sessions: RadiusSessionManager;
|
|
155
|
+
|
|
156
|
+
constructor(clientRef: DcRouterApiClient) {
|
|
157
|
+
this.clientRef = clientRef;
|
|
158
|
+
this.clients = new RadiusClientManager(clientRef);
|
|
159
|
+
this.vlans = new RadiusVlanManager(clientRef);
|
|
160
|
+
this.sessions = new RadiusSessionManager(clientRef);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public async getAccountingSummary(
|
|
164
|
+
startTime: number,
|
|
165
|
+
endTime: number,
|
|
166
|
+
): Promise<interfaces.requests.IReq_GetRadiusAccountingSummary['response']['summary']> {
|
|
167
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_GetRadiusAccountingSummary>(
|
|
168
|
+
'getRadiusAccountingSummary',
|
|
169
|
+
this.clientRef.buildRequestPayload({ startTime, endTime }) as any,
|
|
170
|
+
);
|
|
171
|
+
return response.summary;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public async getStatistics(): Promise<interfaces.requests.IReq_GetRadiusStatistics['response']> {
|
|
175
|
+
return this.clientRef.request<interfaces.requests.IReq_GetRadiusStatistics>(
|
|
176
|
+
'getRadiusStatistics',
|
|
177
|
+
this.clientRef.buildRequestPayload() as any,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import * as interfaces from '../ts_interfaces/index.js';
|
|
2
|
+
import type { DcRouterApiClient } from './classes.dcrouterapiclient.js';
|
|
3
|
+
|
|
4
|
+
export class RemoteIngress {
|
|
5
|
+
private clientRef: DcRouterApiClient;
|
|
6
|
+
|
|
7
|
+
// Data from IRemoteIngress
|
|
8
|
+
public id: string;
|
|
9
|
+
public name: string;
|
|
10
|
+
public secret: string;
|
|
11
|
+
public listenPorts: number[];
|
|
12
|
+
public listenPortsUdp?: number[];
|
|
13
|
+
public enabled: boolean;
|
|
14
|
+
public autoDerivePorts: boolean;
|
|
15
|
+
public tags?: string[];
|
|
16
|
+
public createdAt: number;
|
|
17
|
+
public updatedAt: number;
|
|
18
|
+
public effectiveListenPorts?: number[];
|
|
19
|
+
public effectiveListenPortsUdp?: number[];
|
|
20
|
+
public manualPorts?: number[];
|
|
21
|
+
public derivedPorts?: number[];
|
|
22
|
+
public performance?: interfaces.data.IRemoteIngressPerformanceConfig;
|
|
23
|
+
public egress?: interfaces.data.IRemoteIngressEgressPolicyConfig;
|
|
24
|
+
|
|
25
|
+
constructor(clientRef: DcRouterApiClient, data: interfaces.data.IRemoteIngress) {
|
|
26
|
+
this.clientRef = clientRef;
|
|
27
|
+
this.id = data.id;
|
|
28
|
+
this.name = data.name;
|
|
29
|
+
this.secret = data.secret;
|
|
30
|
+
this.listenPorts = data.listenPorts;
|
|
31
|
+
this.listenPortsUdp = data.listenPortsUdp;
|
|
32
|
+
this.enabled = data.enabled;
|
|
33
|
+
this.autoDerivePorts = data.autoDerivePorts;
|
|
34
|
+
this.tags = data.tags;
|
|
35
|
+
this.createdAt = data.createdAt;
|
|
36
|
+
this.updatedAt = data.updatedAt;
|
|
37
|
+
this.effectiveListenPorts = data.effectiveListenPorts;
|
|
38
|
+
this.effectiveListenPortsUdp = data.effectiveListenPortsUdp;
|
|
39
|
+
this.manualPorts = data.manualPorts;
|
|
40
|
+
this.derivedPorts = data.derivedPorts;
|
|
41
|
+
this.performance = data.performance;
|
|
42
|
+
this.egress = data.egress;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async update(changes: {
|
|
46
|
+
name?: string;
|
|
47
|
+
listenPorts?: number[];
|
|
48
|
+
autoDerivePorts?: boolean;
|
|
49
|
+
enabled?: boolean;
|
|
50
|
+
tags?: string[];
|
|
51
|
+
performance?: interfaces.data.IRemoteIngressPerformanceConfig;
|
|
52
|
+
egress?: interfaces.data.IRemoteIngressEgressPolicyConfig;
|
|
53
|
+
}): Promise<void> {
|
|
54
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_UpdateRemoteIngress>(
|
|
55
|
+
'updateRemoteIngress',
|
|
56
|
+
this.clientRef.buildRequestPayload({ id: this.id, ...changes }) as any,
|
|
57
|
+
);
|
|
58
|
+
if (!response.success) {
|
|
59
|
+
throw new Error('Failed to update remote ingress');
|
|
60
|
+
}
|
|
61
|
+
// Update local state from response
|
|
62
|
+
const edge = response.edge;
|
|
63
|
+
this.name = edge.name;
|
|
64
|
+
this.listenPorts = edge.listenPorts;
|
|
65
|
+
this.listenPortsUdp = edge.listenPortsUdp;
|
|
66
|
+
this.enabled = edge.enabled;
|
|
67
|
+
this.autoDerivePorts = edge.autoDerivePorts;
|
|
68
|
+
this.tags = edge.tags;
|
|
69
|
+
this.updatedAt = edge.updatedAt;
|
|
70
|
+
this.effectiveListenPorts = edge.effectiveListenPorts;
|
|
71
|
+
this.effectiveListenPortsUdp = edge.effectiveListenPortsUdp;
|
|
72
|
+
this.manualPorts = edge.manualPorts;
|
|
73
|
+
this.derivedPorts = edge.derivedPorts;
|
|
74
|
+
this.performance = edge.performance;
|
|
75
|
+
this.egress = edge.egress;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public async delete(): Promise<void> {
|
|
79
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_DeleteRemoteIngress>(
|
|
80
|
+
'deleteRemoteIngress',
|
|
81
|
+
this.clientRef.buildRequestPayload({ id: this.id }) as any,
|
|
82
|
+
);
|
|
83
|
+
if (!response.success) {
|
|
84
|
+
throw new Error(response.message || 'Failed to delete remote ingress');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public async regenerateSecret(): Promise<string> {
|
|
89
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_RegenerateRemoteIngressSecret>(
|
|
90
|
+
'regenerateRemoteIngressSecret',
|
|
91
|
+
this.clientRef.buildRequestPayload({ id: this.id }) as any,
|
|
92
|
+
);
|
|
93
|
+
if (!response.success) {
|
|
94
|
+
throw new Error('Failed to regenerate secret');
|
|
95
|
+
}
|
|
96
|
+
this.secret = response.secret;
|
|
97
|
+
return response.secret;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public async getConnectionToken(hubHost?: string): Promise<string | undefined> {
|
|
101
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_GetRemoteIngressConnectionToken>(
|
|
102
|
+
'getRemoteIngressConnectionToken',
|
|
103
|
+
this.clientRef.buildRequestPayload({ edgeId: this.id, hubHost }) as any,
|
|
104
|
+
);
|
|
105
|
+
if (!response.success) {
|
|
106
|
+
throw new Error(response.message || 'Failed to get connection token');
|
|
107
|
+
}
|
|
108
|
+
return response.token;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class RemoteIngressBuilder {
|
|
113
|
+
private clientRef: DcRouterApiClient;
|
|
114
|
+
private edgeName: string = '';
|
|
115
|
+
private edgeListenPorts?: number[];
|
|
116
|
+
private edgeAutoDerivePorts?: boolean;
|
|
117
|
+
private edgePerformance?: interfaces.data.IRemoteIngressPerformanceConfig;
|
|
118
|
+
private edgeEgress?: interfaces.data.IRemoteIngressEgressPolicyConfig;
|
|
119
|
+
private edgeTags?: string[];
|
|
120
|
+
|
|
121
|
+
constructor(clientRef: DcRouterApiClient) {
|
|
122
|
+
this.clientRef = clientRef;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public setName(name: string): this {
|
|
126
|
+
this.edgeName = name;
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public setListenPorts(ports: number[]): this {
|
|
131
|
+
this.edgeListenPorts = ports;
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public setAutoDerivePorts(auto: boolean): this {
|
|
136
|
+
this.edgeAutoDerivePorts = auto;
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public setTags(tags: string[]): this {
|
|
141
|
+
this.edgeTags = tags;
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public setPerformance(performance: interfaces.data.IRemoteIngressPerformanceConfig): this {
|
|
146
|
+
this.edgePerformance = performance;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public setEgress(egress: interfaces.data.IRemoteIngressEgressPolicyConfig): this {
|
|
151
|
+
this.edgeEgress = egress;
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public async save(): Promise<RemoteIngress> {
|
|
156
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_CreateRemoteIngress>(
|
|
157
|
+
'createRemoteIngress',
|
|
158
|
+
this.clientRef.buildRequestPayload({
|
|
159
|
+
name: this.edgeName,
|
|
160
|
+
listenPorts: this.edgeListenPorts,
|
|
161
|
+
autoDerivePorts: this.edgeAutoDerivePorts,
|
|
162
|
+
performance: this.edgePerformance,
|
|
163
|
+
egress: this.edgeEgress,
|
|
164
|
+
tags: this.edgeTags,
|
|
165
|
+
}) as any,
|
|
166
|
+
);
|
|
167
|
+
if (!response.success) {
|
|
168
|
+
throw new Error('Failed to create remote ingress');
|
|
169
|
+
}
|
|
170
|
+
return new RemoteIngress(this.clientRef, response.edge);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export class RemoteIngressManager {
|
|
175
|
+
private clientRef: DcRouterApiClient;
|
|
176
|
+
|
|
177
|
+
constructor(clientRef: DcRouterApiClient) {
|
|
178
|
+
this.clientRef = clientRef;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
public async list(): Promise<RemoteIngress[]> {
|
|
182
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_GetRemoteIngresses>(
|
|
183
|
+
'getRemoteIngresses',
|
|
184
|
+
this.clientRef.buildRequestPayload() as any,
|
|
185
|
+
);
|
|
186
|
+
return response.edges.map((e) => new RemoteIngress(this.clientRef, e));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public async getStatuses(): Promise<interfaces.data.IRemoteIngressStatus[]> {
|
|
190
|
+
const response = await this.clientRef.request<interfaces.requests.IReq_GetRemoteIngressStatus>(
|
|
191
|
+
'getRemoteIngressStatus',
|
|
192
|
+
this.clientRef.buildRequestPayload() as any,
|
|
193
|
+
);
|
|
194
|
+
return response.statuses;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public async create(options: {
|
|
198
|
+
name: string;
|
|
199
|
+
listenPorts?: number[];
|
|
200
|
+
autoDerivePorts?: boolean;
|
|
201
|
+
performance?: interfaces.data.IRemoteIngressPerformanceConfig;
|
|
202
|
+
egress?: interfaces.data.IRemoteIngressEgressPolicyConfig;
|
|
203
|
+
tags?: string[];
|
|
204
|
+
}): Promise<RemoteIngress> {
|
|
205
|
+
const builder = this.build().setName(options.name);
|
|
206
|
+
if (options.listenPorts) builder.setListenPorts(options.listenPorts);
|
|
207
|
+
if (options.autoDerivePorts !== undefined) builder.setAutoDerivePorts(options.autoDerivePorts);
|
|
208
|
+
if (options.performance) builder.setPerformance(options.performance);
|
|
209
|
+
if (options.egress) builder.setEgress(options.egress);
|
|
210
|
+
if (options.tags) builder.setTags(options.tags);
|
|
211
|
+
return builder.save();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public build(): RemoteIngressBuilder {
|
|
215
|
+
return new RemoteIngressBuilder(this.clientRef);
|
|
216
|
+
}
|
|
217
|
+
}
|