attlaz-client 1.9.55 → 1.9.56
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/Client.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { TriggerEndpoint } from './Service/TriggerEndpoint';
|
|
|
26
26
|
import { PlatformEndpoint } from './Service/PlatformEndpoint';
|
|
27
27
|
import { FlowRunStatsEndpoint } from './Service/FlowRunStatsEndpoint';
|
|
28
28
|
import { CodeSourceBuildStrategyEndpoint } from './Service/CodeSourceBuildStrategyEndpoint';
|
|
29
|
+
import { FirewallEndpoint } from './Service/FirewallEndpoint';
|
|
29
30
|
export declare class Client {
|
|
30
31
|
private readonly apiEndpoint;
|
|
31
32
|
private readonly clientId;
|
|
@@ -71,5 +72,6 @@ export declare class Client {
|
|
|
71
72
|
getQueueEndpoint(): QueueEndpoint;
|
|
72
73
|
getHealthAlertEndpoint(): HealthAlertEndpoint;
|
|
73
74
|
getCodeSourceBuildStrategyEndpoint(): CodeSourceBuildStrategyEndpoint;
|
|
75
|
+
getFirewallEndpoint(): FirewallEndpoint;
|
|
74
76
|
private getEndpoint;
|
|
75
77
|
}
|
package/dist/Client.js
CHANGED
|
@@ -30,6 +30,7 @@ const PlatformEndpoint_1 = require("./Service/PlatformEndpoint");
|
|
|
30
30
|
const FlowRunStatsEndpoint_1 = require("./Service/FlowRunStatsEndpoint");
|
|
31
31
|
const version_1 = require("./version");
|
|
32
32
|
const CodeSourceBuildStrategyEndpoint_1 = require("./Service/CodeSourceBuildStrategyEndpoint");
|
|
33
|
+
const FirewallEndpoint_1 = require("./Service/FirewallEndpoint");
|
|
33
34
|
class Client {
|
|
34
35
|
constructor(apiEndpoint, clientId, clientSecret) {
|
|
35
36
|
this.apiEndpoint = apiEndpoint;
|
|
@@ -61,7 +62,8 @@ class Client {
|
|
|
61
62
|
HealthAlertEndpoint: HealthAlertEndpoint_1.HealthAlertEndpoint,
|
|
62
63
|
PlatformEndpoint: PlatformEndpoint_1.PlatformEndpoint,
|
|
63
64
|
FlowRunStatsEndpoint: FlowRunStatsEndpoint_1.FlowRunStatsEndpoint,
|
|
64
|
-
CodeSourceBuildStrategyEndpoint: CodeSourceBuildStrategyEndpoint_1.CodeSourceBuildStrategyEndpoint
|
|
65
|
+
CodeSourceBuildStrategyEndpoint: CodeSourceBuildStrategyEndpoint_1.CodeSourceBuildStrategyEndpoint,
|
|
66
|
+
FirewallEndpoint: FirewallEndpoint_1.FirewallEndpoint
|
|
65
67
|
};
|
|
66
68
|
const options = new OAuthClientOptions_1.OAuthClientOptions(apiEndpoint, clientId, clientSecret, this.getHeaders());
|
|
67
69
|
this.httpClient = new OAuthClient_1.OAuthClient(options);
|
|
@@ -199,6 +201,10 @@ class Client {
|
|
|
199
201
|
getCodeSourceBuildStrategyEndpoint() {
|
|
200
202
|
return this.getEndpoint('code-source-deploy-strategy', this.Store.CodeSourceBuildStrategyEndpoint);
|
|
201
203
|
}
|
|
204
|
+
// TODO: this should be in a separate API?
|
|
205
|
+
getFirewallEndpoint() {
|
|
206
|
+
return this.getEndpoint('firewall', this.Store.FirewallEndPoint);
|
|
207
|
+
}
|
|
202
208
|
getEndpoint(key, className) {
|
|
203
209
|
//const classNameString: string = className.name;
|
|
204
210
|
if (!this.endpoints.has(key)) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Endpoint } from './Endpoint';
|
|
2
|
+
export declare class FirewallEndpoint extends Endpoint {
|
|
3
|
+
getInformation(): Promise<{
|
|
4
|
+
blocked_ips: any[];
|
|
5
|
+
flagged_ips: any[];
|
|
6
|
+
ip_rules: [];
|
|
7
|
+
} | null>;
|
|
8
|
+
createIpRule(ip: string, action: string, description?: string): Promise<boolean>;
|
|
9
|
+
unblockIP(ip: string): Promise<boolean>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirewallEndpoint = void 0;
|
|
4
|
+
const Endpoint_1 = require("./Endpoint");
|
|
5
|
+
class FirewallEndpoint extends Endpoint_1.Endpoint {
|
|
6
|
+
async getInformation() {
|
|
7
|
+
let cmd = '/system/firewall/';
|
|
8
|
+
try {
|
|
9
|
+
const parser = (raw) => {
|
|
10
|
+
const info = {
|
|
11
|
+
blocked_ips: raw.blocked_ips,
|
|
12
|
+
flagged_ips: raw.flagged_ips,
|
|
13
|
+
ip_rules: raw.ip_rules,
|
|
14
|
+
};
|
|
15
|
+
return info;
|
|
16
|
+
};
|
|
17
|
+
const result = await this.requestObject(cmd, null, parser, 'GET');
|
|
18
|
+
return result.getData();
|
|
19
|
+
}
|
|
20
|
+
catch (ex) {
|
|
21
|
+
if (this.httpClient.isDebugEnabled()) {
|
|
22
|
+
console.error('Failed to get firewall information', ex);
|
|
23
|
+
}
|
|
24
|
+
throw ex;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async createIpRule(ip, action, description = '') {
|
|
28
|
+
let cmd = '/system/firewall/ip_rules';
|
|
29
|
+
try {
|
|
30
|
+
const parser = (raw) => {
|
|
31
|
+
return raw.success;
|
|
32
|
+
};
|
|
33
|
+
const result = await this.requestObject(cmd, { ip, action, description }, parser, 'PUT');
|
|
34
|
+
const re = result.getData();
|
|
35
|
+
if (re === null) {
|
|
36
|
+
console.log('createIPRule wrong result', { result, parsed: re });
|
|
37
|
+
throw new Error('Unable to create IP rule: wrong response from API');
|
|
38
|
+
}
|
|
39
|
+
return re.success;
|
|
40
|
+
}
|
|
41
|
+
catch (ex) {
|
|
42
|
+
if (this.httpClient.isDebugEnabled()) {
|
|
43
|
+
console.error('Failed to create IP rule', ex);
|
|
44
|
+
}
|
|
45
|
+
throw ex;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async unblockIP(ip) {
|
|
49
|
+
let cmd = '/system/firewall/blocked_ips';
|
|
50
|
+
try {
|
|
51
|
+
const parser = (raw) => {
|
|
52
|
+
return { success: raw.success };
|
|
53
|
+
};
|
|
54
|
+
const result = await this.requestObject(cmd, { ip }, parser, 'DELETE');
|
|
55
|
+
const x = result.getData();
|
|
56
|
+
if (x === null) {
|
|
57
|
+
console.log('Unblock ip wrong response', { result, parsed: x });
|
|
58
|
+
throw new Error('Unable to unblock ip: wrong response from API');
|
|
59
|
+
}
|
|
60
|
+
return x.success;
|
|
61
|
+
}
|
|
62
|
+
catch (ex) {
|
|
63
|
+
if (this.httpClient.isDebugEnabled()) {
|
|
64
|
+
console.error('Unable to unblock ip', ex);
|
|
65
|
+
}
|
|
66
|
+
throw ex;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.FirewallEndpoint = FirewallEndpoint;
|