-
Notifications
You must be signed in to change notification settings - Fork 4
/
ali.js
81 lines (74 loc) · 1.58 KB
/
ali.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const ECS = require("./compute/ali-ecs");
const SLB = require("./networking/ali-slb");
const RDS = require("./database/ali-rds");
const OSS = require("./storage/ali-oss");
class AliCloud {
/**
* Expose AliCloud APIs
* @constructor
*/
constructor(aliSDK, accessKeyId, secretAccessKey, bucketName, bucketRegion) {
this._aliSDK = aliSDK;
this._accessKeyId = accessKeyId;
this._secretAccessKey = secretAccessKey;
this._bucketName = bucketName;
this._bucketRegion = bucketRegion;
return {
getSDK: () => this._aliSDK,
getAccessKeyId: () => this._accessKeyId,
getSecretAccessKey: () => this._secretAccessKey,
getBucketName: () => this._bucketName,
getBucketRegion: () => this._bucketRegion,
ecs: this.ECS,
slb: this.SLB,
rds: this.RDS,
oss: this.OSS
};
}
/**
* Compute - ECS Wrapper
* @ECS
*/
ECS() {
return new ECS(
this.getSDK(),
this.getAccessKeyId(),
this.getSecretAccessKey()
);
}
/**
* Networking - SLB Wrapper
* @SLB
*/
SLB() {
return new SLB(
this.getSDK(),
this.getAccessKeyId(),
this.getSecretAccessKey()
);
}
/**
* Database - ApsaraDB for RDS Wrapper
* @RDS
*/
RDS() {
return new RDS(
this.getSDK(),
this.getAccessKeyId(),
this.getSecretAccessKey()
);
}
/**
* Storage - OSS Wrapper
* @OSS
*/
OSS() {
return new OSS(
this.getAccessKeyId(),
this.getSecretAccessKey(),
this.getBucketName(),
this.getBucketRegion()
);
}
}
module.exports = AliCloud;