-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathgcp.js
101 lines (90 loc) · 2.35 KB
/
gcp.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const googleCompute = require("./compute/google");
const googleStorage = require("./storage/google-compute");
const googleStorageBucket = require("./storage/google-storage");
const googleDNS = require("./network/google-dns");
const googleDatastore = require("./database/google-datastore");
const googleAutoML = require("./artificialInteligence/autoML");
class Google {
/**
* Expose GCP/Google APIs
* @constructor
*/
constructor(config, googleSDK) {
this._googleSDK = googleSDK;
this._config = config;
if (!config.projectId && config.keyFilename) {
throw new Error(
"Provide parameters <link to docs> i.e: projectId, keyFilename"
);
}
return {
getSDK: () => this._googleSDK,
getConfig: () => this._config,
compute: this.googleCompute,
storage: this.googleStorage,
bucket: this.googleStorageBucket,
dns: this.googleDNS,
nosql: this.googleDatastore,
autoML: this.googleAutoML
};
}
/**
* GCP compute Wrapper
* @googleCompute
* @param {object} params - { apiVersion }
*/
googleCompute(params) {
return new googleCompute(this.getSDK(), this._config);
}
/**
* GCP storage Wrapper
* @googleCompute
* @param {object} params - { apiVersion }
*/
googleStorage(params) {
return new googleStorage(this.getSDK(), this._config);
}
/**
* GCP storage bucket Wrapper
* @googleStorageBucket
* @param {object} params - { apiVersion }
*/
googleStorageBucket(params) {
if (params === undefined) {
return new googleStorageBucket(this.getSDK(), this._config);
}
return new googleStorageBucket(
this.getSDK(),
this._config,
params.bucketName
);
}
/**
* GCP DNS wrapper
* @googleDNS
* @param {object} params - { apiVersion }
*/
googleDNS(params) {
if (params === undefined) {
return new googleDNS(this.getSDK(), this._config);
}
return new googleDNS(this.getSDK(), this._config);
}
/**
* GCP Datastore wrapper
* @googleDatastore
* @param {object} params - { apiVersion }
*/
googleDatastore(params) {
return new googleDatastore(this.getSDK());
}
/**
* GCP autoML Wrapper
* @googleAutoML
* @param {object} params - { apiVersion }
*/
googleAutoML() {
return new googleAutoML(this.getSDK(), this.getConfig());
}
}
module.exports = Google;