This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathankrAPI.js
218 lines (189 loc) · 5.1 KB
/
ankrAPI.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// user
changeEmail = async function (email_u) {
await authenticateUserAcct()
await reqA('POST', '/change_email', {
new_email: email_u
})
}
forgotPassword = async function (email) {
await authenticateUserAcct()
await reqA('POST', '/forgot_password', {
email: email
})
}
changePassword = async function (old_p, new_p) {
await authenticateUserAcct()
await reqA('POST', '/change_password',{
old_password: old_p,
new_password: new_p
})
}
// chart
chartList = async function (repo = 'stable') {
await authenticateUserAcct()
const list = await reqA('GET', '/chart/list', {chart_repo: repo})
console.log(list)
return list
}
chartDetail = async function (repo, name, ver) {
await authenticateUserAcct()
path = '/chart/detail/' + repo + '/' + name + '/' + ver
const chart_detail1 = await reqA('GET', path)
console.log(chart_detail1)
return chart_detail1
}
chartDownload = async function (repo, name, ver) {
await authenticateUserAcct()
path = '/chart/download/' + repo + '/' + name + '/' + ver
const file = await reqA('GET', path)
console.log(file)
return file
}
chartDelete = async function (name, ver) {
await authenticateUserAcct()
delete_path = '/chart/delete/' + 'user' + '/' + name + '/' + ver
await reqA('DELETE', delete_path)
}
chartUpload = async function (repo, name, ver, file) {
await authenticateUserAcct()
const upload_path = '/chart/upload/' + repo + '/' + name + '/' + ver
await reqA('POST', upload_path,{
chart_file: file
})
}
// dc
dcList = async function () {
await authenticateUserAcct()
const list = await reqA('GET', '/dc/list')
console.log(list)
return list
}
dcNetworkInfo = async function () {
await authenticateUserAcct()
const networkInfo = await reqA('GET', '/dc/networkinfo')
console.log(networkInfo)
return networkInfo
}
myDc = async function () {
await authenticateUserAcct()
const cluster = await reqA('GET', '/dc/mydc')
console.log(cluster)
return cluster
}
dcReset = async function (reset_name) {
await authenticateUserAcct()
const cluster = await reqA('POST', '/dc/reset' , {
cluster_name: reset_name})
console.log(cluster)
return cluster
}
// namespace
namespaceList = async function () {
await authenticateUserAcct()
const nsList = await reqA('GET', '/namespace/list')
console.log(nsList)
return nsList
}
namespaceCreate = async function (ns_name, ns_cpu_limit, ns_mem_limit, ns_storage_limit) {
await authenticateUserAcct()
const namespace = await reqA('POST', '/namespace/create', {
ns_name: ns_name,
ns_cpu_limit: ns_cpu_limit,
ns_mem_limit: ns_mem_limit,
ns_storage_limit: ns_storage_limit
})
console.log(namespace)
return namespace
}
namespaceDelete = async function (ns_id) {
await authenticateUserAcct()
path = '/namespace/delete/' + ns_id
await reqA('DELETE', path)
}
namespaceUpdate = async function (ns_id, cpu_u, mem_u, storage_u) {
await authenticateUserAcct()
await reqA('POST', '/namespace/update', {
ns_id: ns_id,
ns_cpu_limit: cpu_u,
ns_mem_limit: mem_u,
ns_storage_limit: storage_u
})
}
// app
appList = async function () {
await authenticateUserAcct()
const appList = await reqA('GET', '/app/list')
console.log(appList)
return appList
}
appCreate = async function (app_name, chart_repo, chart_name, chart_ver, ns_id, custom_values = []) {
await authenticateUserAcct()
const app = await reqA('POST', '/app/create', {
app_name: app_name,
chart: {
chart_name: chart_name,
chart_repo: chart_repo,
chart_ver: chart_ver
},
ns_id: ns_id,
custom_values: custom_values
})
console.log(app)
return app
}
appCancel = async function (app_id) {
await authenticateUserAcct()
path_cancel = '/app/cancel/' + app_id
await reqA('POST', path_cancel)
}
appPurge = async function (app_id) {
await authenticateUserAcct()
path_purge = '/app/cancel/' + app_id
await reqA('DELETE', path_purge)
}
appUpdate = async function (app_id, app_name_u, chart_name_u, chart_repo_u, chart_ver_u) {
await authenticateUserAcct()
path = '/app/update/' + app_id
await reqA('POST', path, {
app_name: app_name_u,
chart_name: chart_name_u,
chart_repo: chart_repo_u,
chart_ver: chart_ver_u
})
}
appDetail = async function (app_id) {
await authenticateUserAcct()
path = "/app/detail/" + app_id
const detail = await reqA('GET', path)
console.log(detail)
return detail
}
module.exports = {
//user
changeEmail,
forgotPassword,
changePassword,
// chart
chartList,
chartDetail,
chartDownload,
chartDelete,
chartUpload,
// namespace
namespaceList,
namespaceCreate,
namespaceDelete,
namespaceUpdate,
// dc
dcList,
dcNetworkInfo,
myDc,
dcReset,
// app
appList,
appCreate,
appCancel,
appPurge,
appUpdate,
appDetail,
}