caprover-api 0.0.1
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/.prettierrc.json +6 -0
- package/.vscode/settings.json +6 -0
- package/.yarnrc.yml +1 -0
- package/README.md +44 -0
- package/dist/api/ApiManager.d.ts +114 -0
- package/dist/api/ApiManager.js +486 -0
- package/dist/api/ErrorFactory.d.ts +26 -0
- package/dist/api/ErrorFactory.js +35 -0
- package/dist/api/HttpClient.d.ts +16 -0
- package/dist/api/HttpClient.js +130 -0
- package/dist/example.d.ts +1 -0
- package/dist/example.js +30 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +43 -0
- package/dist/models/AppDefinition.d.ts +105 -0
- package/dist/models/AppDefinition.js +2 -0
- package/dist/models/AppDefinitionsResponse.d.ts +7 -0
- package/dist/models/AppDefinitionsResponse.js +2 -0
- package/dist/models/AppDeleteResponse.d.ts +3 -0
- package/dist/models/AppDeleteResponse.js +2 -0
- package/dist/models/AutomatedCleanupConfigs.d.ts +12 -0
- package/dist/models/AutomatedCleanupConfigs.js +15 -0
- package/dist/models/BackupMeta.d.ts +19 -0
- package/dist/models/BackupMeta.js +2 -0
- package/dist/models/BuildLogsResponse.d.ts +8 -0
- package/dist/models/BuildLogsResponse.js +2 -0
- package/dist/models/CapRoverTheme.d.ts +10 -0
- package/dist/models/CapRoverTheme.js +2 -0
- package/dist/models/CaptainInfo.d.ts +6 -0
- package/dist/models/CaptainInfo.js +2 -0
- package/dist/models/ContainerProps.d.ts +3 -0
- package/dist/models/ContainerProps.js +2 -0
- package/dist/models/DockerAuthObj.d.ts +11 -0
- package/dist/models/DockerAuthObj.js +2 -0
- package/dist/models/DockerSecret.d.ts +4 -0
- package/dist/models/DockerSecret.js +2 -0
- package/dist/models/DockerService.d.ts +99 -0
- package/dist/models/DockerService.js +2 -0
- package/dist/models/GoAccessInfo.d.ts +7 -0
- package/dist/models/GoAccessInfo.js +2 -0
- package/dist/models/GoAccessReportResponse.d.ts +6 -0
- package/dist/models/GoAccessReportResponse.js +2 -0
- package/dist/models/IBuiltImage.d.ts +4 -0
- package/dist/models/IBuiltImage.js +2 -0
- package/dist/models/ICaptainDefinition.d.ts +7 -0
- package/dist/models/ICaptainDefinition.js +2 -0
- package/dist/models/IGoAccessInfo.d.ts +7 -0
- package/dist/models/IGoAccessInfo.js +2 -0
- package/dist/models/IHashMapGeneric.d.ts +3 -0
- package/dist/models/IHashMapGeneric.js +2 -0
- package/dist/models/IImageSource.d.ts +12 -0
- package/dist/models/IImageSource.js +2 -0
- package/dist/models/IOneClickAppModels.d.ts +45 -0
- package/dist/models/IOneClickAppModels.js +2 -0
- package/dist/models/IProFeatures.d.ts +32 -0
- package/dist/models/IProFeatures.js +14 -0
- package/dist/models/IRegistryInfo.d.ts +21 -0
- package/dist/models/IRegistryInfo.js +8 -0
- package/dist/models/IServerBlockDetails.d.ts +17 -0
- package/dist/models/IServerBlockDetails.js +2 -0
- package/dist/models/IVersionInfo.d.ts +6 -0
- package/dist/models/IVersionInfo.js +2 -0
- package/dist/models/LoadBalancerInfo.d.ts +9 -0
- package/dist/models/LoadBalancerInfo.js +2 -0
- package/dist/models/LogsResponse.d.ts +3 -0
- package/dist/models/LogsResponse.js +2 -0
- package/dist/models/NetDataInfo.d.ts +27 -0
- package/dist/models/NetDataInfo.js +2 -0
- package/dist/models/NginxConfig.d.ts +10 -0
- package/dist/models/NginxConfig.js +2 -0
- package/dist/models/OneClickAppDefinitionResponse.d.ts +3 -0
- package/dist/models/OneClickAppDefinitionResponse.js +2 -0
- package/dist/models/OneClickAppRepositories.d.ts +3 -0
- package/dist/models/OneClickAppRepositories.js +2 -0
- package/dist/models/OneClickAppResponse.d.ts +4 -0
- package/dist/models/OneClickAppResponse.js +2 -0
- package/dist/models/OtherTypes.d.ts +29 -0
- package/dist/models/OtherTypes.js +2 -0
- package/dist/models/ProjectDefinition.d.ts +6 -0
- package/dist/models/ProjectDefinition.js +2 -0
- package/dist/models/ProjectsResponse.d.ts +4 -0
- package/dist/models/ProjectsResponse.js +2 -0
- package/dist/models/RegistriesResponse.d.ts +5 -0
- package/dist/models/RegistriesResponse.js +2 -0
- package/dist/models/ServerDockerInfo.d.ts +14 -0
- package/dist/models/ServerDockerInfo.js +2 -0
- package/dist/models/UnusedImagesResponse.d.ts +6 -0
- package/dist/models/UnusedImagesResponse.js +2 -0
- package/dist/models/index.d.ts +40 -0
- package/dist/models/index.js +56 -0
- package/package.json +30 -0
- package/src/api/ApiManager.ts +825 -0
- package/src/api/ErrorFactory.ts +35 -0
- package/src/api/HttpClient.ts +143 -0
- package/src/example.ts +36 -0
- package/src/index.ts +5 -0
- package/src/models/AppDefinition.ts +124 -0
- package/src/models/AppDefinitionsResponse.ts +8 -0
- package/src/models/AppDeleteResponse.ts +3 -0
- package/src/models/AutomatedCleanupConfigs.ts +18 -0
- package/src/models/BackupMeta.ts +26 -0
- package/src/models/BuildLogsResponse.ts +5 -0
- package/src/models/CapRoverTheme.ts +11 -0
- package/src/models/CaptainInfo.ts +6 -0
- package/src/models/ContainerProps.ts +3 -0
- package/src/models/DockerAuthObj.ts +25 -0
- package/src/models/DockerSecret.ts +4 -0
- package/src/models/DockerService.ts +117 -0
- package/src/models/GoAccessInfo.ts +7 -0
- package/src/models/GoAccessReportResponse.ts +6 -0
- package/src/models/IBuiltImage.ts +4 -0
- package/src/models/ICaptainDefinition.ts +7 -0
- package/src/models/IGoAccessInfo.ts +7 -0
- package/src/models/IHashMapGeneric.ts +3 -0
- package/src/models/IImageSource.ts +10 -0
- package/src/models/IOneClickAppModels.ts +51 -0
- package/src/models/IProFeatures.ts +39 -0
- package/src/models/IRegistryInfo.ts +30 -0
- package/src/models/IServerBlockDetails.ts +18 -0
- package/src/models/IVersionInfo.ts +6 -0
- package/src/models/LoadBalancerInfo.ts +11 -0
- package/src/models/LogsResponse.ts +3 -0
- package/src/models/NetDataInfo.ts +27 -0
- package/src/models/NginxConfig.ts +10 -0
- package/src/models/OneClickAppDefinitionResponse.ts +3 -0
- package/src/models/OneClickAppRepositories.ts +3 -0
- package/src/models/OneClickAppResponse.ts +5 -0
- package/src/models/OtherTypes.ts +32 -0
- package/src/models/ProjectDefinition.ts +6 -0
- package/src/models/ProjectsResponse.ts +5 -0
- package/src/models/RegistriesResponse.ts +6 -0
- package/src/models/ServerDockerInfo.ts +14 -0
- package/src/models/UnusedImagesResponse.ts +3 -0
- package/src/models/index.ts +41 -0
- package/tsconfig.json +14 -0
- package/tslint.json +46 -0
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
import { IAppDef } from '../models/AppDefinition'
|
|
2
|
+
import AppDefinitionsResponse from '../models/AppDefinitionsResponse'
|
|
3
|
+
import AppDeleteResponse from '../models/AppDeleteResponse'
|
|
4
|
+
import { IAutomatedCleanupConfigs } from '../models/AutomatedCleanupConfigs'
|
|
5
|
+
import { BuildLogsResponse } from '../models/BuildLogsResponse'
|
|
6
|
+
import CapRoverTheme from '../models/CapRoverTheme'
|
|
7
|
+
import CaptainInfo from '../models/CaptainInfo'
|
|
8
|
+
import { GoAccessInfo } from '../models/GoAccessInfo'
|
|
9
|
+
import GoAccessReportResponse from '../models/GoAccessReportResponse'
|
|
10
|
+
import { ICaptainDefinition } from '../models/ICaptainDefinition'
|
|
11
|
+
import IGoAccessInfo from '../models/IGoAccessInfo'
|
|
12
|
+
import {
|
|
13
|
+
IProConfig,
|
|
14
|
+
IProFeatures,
|
|
15
|
+
TwoFactorAuthRequest,
|
|
16
|
+
TwoFactorAuthResponse,
|
|
17
|
+
} from '../models/IProFeatures'
|
|
18
|
+
import { IRegistryInfo } from '../models/IRegistryInfo'
|
|
19
|
+
import { IVersionInfo } from '../models/IVersionInfo'
|
|
20
|
+
import LoadBalancerInfo from '../models/LoadBalancerInfo'
|
|
21
|
+
import LogsResponse from '../models/LogsResponse'
|
|
22
|
+
import { NetDataInfo } from '../models/NetDataInfo'
|
|
23
|
+
import NginxConfig from '../models/NginxConfig'
|
|
24
|
+
import OneClickAppDefinitionResponse from '../models/OneClickAppDefinitionResponse'
|
|
25
|
+
import OneClickAppRepositories from '../models/OneClickAppRepositories'
|
|
26
|
+
import OneClickAppResponse from '../models/OneClickAppResponse'
|
|
27
|
+
import { ProjectDefinition } from '../models/ProjectDefinition'
|
|
28
|
+
import ProjectsResponse from '../models/ProjectsResponse'
|
|
29
|
+
import RegistriesResponse from '../models/RegistriesResponse'
|
|
30
|
+
import { ServerDockerInfo } from '../models/ServerDockerInfo'
|
|
31
|
+
import UnusedImagesResponse from '../models/UnusedImagesResponse'
|
|
32
|
+
import HttpClient from './HttpClient'
|
|
33
|
+
|
|
34
|
+
export type AuthenticationContent = {
|
|
35
|
+
password: string
|
|
36
|
+
otpToken?: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type AuthRequiredCallback = () => Promise<AuthenticationContent>
|
|
40
|
+
|
|
41
|
+
export default class ApiManager {
|
|
42
|
+
private http: HttpClient
|
|
43
|
+
|
|
44
|
+
constructor(
|
|
45
|
+
baseDomain: string,
|
|
46
|
+
private authCallback: AuthRequiredCallback
|
|
47
|
+
) {
|
|
48
|
+
const self = this
|
|
49
|
+
const URL = baseDomain + '/api/v2'
|
|
50
|
+
this.http = new HttpClient(URL, function () {
|
|
51
|
+
return self.getAuthToken()
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
destroy() {
|
|
56
|
+
this.http.destroy()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getAuthToken(): Promise<string> {
|
|
60
|
+
const self = this
|
|
61
|
+
const http = self.http
|
|
62
|
+
|
|
63
|
+
return Promise.resolve() //
|
|
64
|
+
.then(() => {
|
|
65
|
+
return self.authCallback()
|
|
66
|
+
})
|
|
67
|
+
.then((authContent) => {
|
|
68
|
+
return Promise.resolve() //
|
|
69
|
+
.then(
|
|
70
|
+
http.fetch(http.POST, '/login', {
|
|
71
|
+
password: authContent?.password,
|
|
72
|
+
otpToken: authContent?.otpToken,
|
|
73
|
+
})
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
.then(function (data) {
|
|
77
|
+
return data.token
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getAllThemes(): Promise<{ themes: CapRoverTheme[] | undefined }> {
|
|
82
|
+
const http = this.http
|
|
83
|
+
|
|
84
|
+
return Promise.resolve() //
|
|
85
|
+
.then(http.fetch(http.GET, '/user/system/themes/all', {}))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getCurrentTheme(): Promise<{ theme: CapRoverTheme }> {
|
|
89
|
+
const http = this.http
|
|
90
|
+
|
|
91
|
+
return Promise.resolve() //
|
|
92
|
+
.then(http.fetch(http.GET, '/theme/current', {}))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setCurrentTheme(themeName: string): Promise<{}> {
|
|
96
|
+
const http = this.http
|
|
97
|
+
|
|
98
|
+
return Promise.resolve() //
|
|
99
|
+
.then(
|
|
100
|
+
http.fetch(http.POST, '/user/system/themes/setcurrent', {
|
|
101
|
+
themeName,
|
|
102
|
+
})
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
saveTheme(oldName: string, theme: CapRoverTheme): Promise<{}> {
|
|
107
|
+
const http = this.http
|
|
108
|
+
|
|
109
|
+
return Promise.resolve() //
|
|
110
|
+
.then(
|
|
111
|
+
http.fetch(http.POST, '/user/system/themes/update', {
|
|
112
|
+
oldName,
|
|
113
|
+
name: theme.name,
|
|
114
|
+
content: theme.content,
|
|
115
|
+
})
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
deleteTheme(themeName: string): Promise<{}> {
|
|
120
|
+
const http = this.http
|
|
121
|
+
|
|
122
|
+
return Promise.resolve() //
|
|
123
|
+
.then(
|
|
124
|
+
http.fetch(http.POST, '/user/system/themes/delete', {
|
|
125
|
+
themeName,
|
|
126
|
+
})
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
getProFeaturesState(): Promise<{ proFeaturesState: IProFeatures }> {
|
|
131
|
+
const http = this.http
|
|
132
|
+
|
|
133
|
+
return Promise.resolve() //
|
|
134
|
+
.then(http.fetch(http.GET, '/user/pro/state', {}))
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
setProApiKey(apiKey: string): Promise<void> {
|
|
138
|
+
const http = this.http
|
|
139
|
+
|
|
140
|
+
return Promise.resolve() //
|
|
141
|
+
.then(http.fetch(http.POST, '/user/pro/apikey', { apiKey: apiKey }))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getProConfigs(): Promise<{ proConfigs: IProConfig }> {
|
|
145
|
+
const http = this.http
|
|
146
|
+
|
|
147
|
+
return Promise.resolve() //
|
|
148
|
+
.then(http.fetch(http.GET, '/user/pro/configs', {}))
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
setProConfigs(data: IProConfig): Promise<void> {
|
|
152
|
+
const http = this.http
|
|
153
|
+
|
|
154
|
+
return Promise.resolve() //
|
|
155
|
+
.then(
|
|
156
|
+
http.fetch(http.POST, '/user/pro/configs', { proConfigs: data })
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
getOtpStatus(): Promise<TwoFactorAuthResponse> {
|
|
161
|
+
const http = this.http
|
|
162
|
+
|
|
163
|
+
return Promise.resolve() //
|
|
164
|
+
.then(http.fetch(http.GET, '/user/pro/otp', {}))
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
setOtpStatus(data: TwoFactorAuthRequest): Promise<TwoFactorAuthResponse> {
|
|
168
|
+
const http = this.http
|
|
169
|
+
|
|
170
|
+
return Promise.resolve() //
|
|
171
|
+
.then(http.fetch(http.POST, '/user/pro/otp', data))
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
getCaptainInfo(): Promise<CaptainInfo> {
|
|
175
|
+
const http = this.http
|
|
176
|
+
|
|
177
|
+
return Promise.resolve() //
|
|
178
|
+
.then(http.fetch(http.GET, '/user/system/info', {}))
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
updateRootDomain(rootDomain: string, force: boolean): Promise<void> {
|
|
182
|
+
const http = this.http
|
|
183
|
+
|
|
184
|
+
return Promise.resolve() //
|
|
185
|
+
.then(
|
|
186
|
+
http.fetch(http.POST, '/user/system/changerootdomain', {
|
|
187
|
+
rootDomain,
|
|
188
|
+
force,
|
|
189
|
+
})
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
enableRootSsl(emailAddress: string): Promise<void> {
|
|
194
|
+
const http = this.http
|
|
195
|
+
|
|
196
|
+
return Promise.resolve() //
|
|
197
|
+
.then(
|
|
198
|
+
http.fetch(http.POST, '/user/system/enablessl', {
|
|
199
|
+
emailAddress,
|
|
200
|
+
})
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
forceSsl(isEnabled: boolean): Promise<void> {
|
|
205
|
+
const http = this.http
|
|
206
|
+
|
|
207
|
+
return Promise.resolve() //
|
|
208
|
+
.then(http.fetch(http.POST, '/user/system/forcessl', { isEnabled }))
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
getAllApps(): Promise<AppDefinitionsResponse> {
|
|
212
|
+
const http = this.http
|
|
213
|
+
|
|
214
|
+
return Promise.resolve() //
|
|
215
|
+
.then(http.fetch(http.GET, '/user/apps/appDefinitions', {}))
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
getAllProjects(): Promise<ProjectsResponse> {
|
|
219
|
+
const http = this.http
|
|
220
|
+
|
|
221
|
+
return Promise.resolve() //
|
|
222
|
+
.then(http.fetch(http.GET, '/user/projects', {}))
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
fetchBuildLogs(appName: string): Promise<BuildLogsResponse> {
|
|
226
|
+
const http = this.http
|
|
227
|
+
|
|
228
|
+
return Promise.resolve() //
|
|
229
|
+
.then(http.fetch(http.GET, `/user/apps/appData/${appName}`, {}))
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
fetchAppLogsInHex(appName: string): Promise<LogsResponse> {
|
|
233
|
+
const http = this.http
|
|
234
|
+
|
|
235
|
+
return Promise.resolve() //
|
|
236
|
+
.then(
|
|
237
|
+
http.fetch(
|
|
238
|
+
http.GET,
|
|
239
|
+
`/user/apps/appData/${appName}/logs?encoding=hex`,
|
|
240
|
+
{}
|
|
241
|
+
)
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
uploadAppData(appName: string, file: File): Promise<void> {
|
|
246
|
+
const http = this.http
|
|
247
|
+
let formData = new FormData()
|
|
248
|
+
formData.append('sourceFile', file)
|
|
249
|
+
return Promise.resolve() //
|
|
250
|
+
.then(
|
|
251
|
+
http.fetch(
|
|
252
|
+
http.POST,
|
|
253
|
+
`/user/apps/appData/${appName}?detached=1`,
|
|
254
|
+
formData
|
|
255
|
+
)
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
registerProject(
|
|
260
|
+
selectedProject: ProjectDefinition
|
|
261
|
+
): Promise<ProjectDefinition> {
|
|
262
|
+
const http = this.http
|
|
263
|
+
return Promise.resolve() //
|
|
264
|
+
.then(
|
|
265
|
+
http.fetch(http.POST, '/user/projects/register', {
|
|
266
|
+
...selectedProject,
|
|
267
|
+
})
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
updateProject(project: ProjectDefinition): Promise<void> {
|
|
272
|
+
const http = this.http
|
|
273
|
+
return Promise.resolve() //
|
|
274
|
+
.then(
|
|
275
|
+
http.fetch(http.POST, '/user/projects/update', {
|
|
276
|
+
projectDefinition: project,
|
|
277
|
+
})
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
uploadCaptainDefinitionContent(
|
|
282
|
+
appName: string,
|
|
283
|
+
captainDefinition: ICaptainDefinition,
|
|
284
|
+
gitHash: string,
|
|
285
|
+
detached: boolean
|
|
286
|
+
): Promise<void> {
|
|
287
|
+
const http = this.http
|
|
288
|
+
|
|
289
|
+
return Promise.resolve() //
|
|
290
|
+
.then(
|
|
291
|
+
http.fetch(
|
|
292
|
+
http.POST,
|
|
293
|
+
`/user/apps/appData/${appName}${
|
|
294
|
+
detached ? '?detached=1' : ''
|
|
295
|
+
}`,
|
|
296
|
+
{
|
|
297
|
+
captainDefinitionContent:
|
|
298
|
+
JSON.stringify(captainDefinition),
|
|
299
|
+
gitHash,
|
|
300
|
+
}
|
|
301
|
+
)
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
updateConfigAndSave(
|
|
306
|
+
appName: string,
|
|
307
|
+
appDefinition: IAppDef
|
|
308
|
+
): Promise<void> {
|
|
309
|
+
let instanceCount = appDefinition.instanceCount
|
|
310
|
+
let captainDefinitionRelativeFilePath =
|
|
311
|
+
appDefinition.captainDefinitionRelativeFilePath
|
|
312
|
+
let envVars = appDefinition.envVars
|
|
313
|
+
let notExposeAsWebApp = appDefinition.notExposeAsWebApp
|
|
314
|
+
let forceSsl = appDefinition.forceSsl
|
|
315
|
+
let websocketSupport = appDefinition.websocketSupport
|
|
316
|
+
let volumes = appDefinition.volumes
|
|
317
|
+
let ports = appDefinition.ports
|
|
318
|
+
let nodeId = appDefinition.nodeId
|
|
319
|
+
let appPushWebhook = appDefinition.appPushWebhook
|
|
320
|
+
let customNginxConfig = appDefinition.customNginxConfig
|
|
321
|
+
let preDeployFunction = appDefinition.preDeployFunction
|
|
322
|
+
let serviceUpdateOverride = appDefinition.serviceUpdateOverride
|
|
323
|
+
let containerHttpPort = appDefinition.containerHttpPort
|
|
324
|
+
let description = appDefinition.description
|
|
325
|
+
let httpAuth = appDefinition.httpAuth
|
|
326
|
+
let appDeployTokenConfig = appDefinition.appDeployTokenConfig
|
|
327
|
+
let tags = appDefinition.tags
|
|
328
|
+
let redirectDomain = appDefinition.redirectDomain
|
|
329
|
+
let projectId = appDefinition.projectId
|
|
330
|
+
const http = this.http
|
|
331
|
+
|
|
332
|
+
return Promise.resolve() //
|
|
333
|
+
.then(
|
|
334
|
+
http.fetch(http.POST, '/user/apps/appDefinitions/update', {
|
|
335
|
+
appName: appName,
|
|
336
|
+
instanceCount: instanceCount,
|
|
337
|
+
captainDefinitionRelativeFilePath:
|
|
338
|
+
captainDefinitionRelativeFilePath,
|
|
339
|
+
notExposeAsWebApp: notExposeAsWebApp,
|
|
340
|
+
forceSsl: forceSsl,
|
|
341
|
+
websocketSupport: websocketSupport,
|
|
342
|
+
volumes: volumes,
|
|
343
|
+
ports: ports,
|
|
344
|
+
customNginxConfig: customNginxConfig,
|
|
345
|
+
appPushWebhook: appPushWebhook,
|
|
346
|
+
nodeId: nodeId,
|
|
347
|
+
preDeployFunction: preDeployFunction,
|
|
348
|
+
serviceUpdateOverride: serviceUpdateOverride,
|
|
349
|
+
containerHttpPort: containerHttpPort,
|
|
350
|
+
description: description,
|
|
351
|
+
httpAuth: httpAuth,
|
|
352
|
+
envVars: envVars,
|
|
353
|
+
appDeployTokenConfig: appDeployTokenConfig,
|
|
354
|
+
tags: tags,
|
|
355
|
+
redirectDomain: redirectDomain,
|
|
356
|
+
projectId: projectId,
|
|
357
|
+
})
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
renameApp(oldAppName: string, newAppName: string): Promise<void> {
|
|
362
|
+
const http = this.http
|
|
363
|
+
|
|
364
|
+
return Promise.resolve() //
|
|
365
|
+
.then(
|
|
366
|
+
http.fetch(http.POST, '/user/apps/appDefinitions/rename', {
|
|
367
|
+
oldAppName,
|
|
368
|
+
newAppName,
|
|
369
|
+
})
|
|
370
|
+
)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
registerNewApp(
|
|
374
|
+
appName: string,
|
|
375
|
+
projectId: string,
|
|
376
|
+
hasPersistentData: boolean,
|
|
377
|
+
detached: boolean
|
|
378
|
+
): Promise<void> {
|
|
379
|
+
const http = this.http
|
|
380
|
+
|
|
381
|
+
return Promise.resolve() //
|
|
382
|
+
.then(
|
|
383
|
+
http.fetch(
|
|
384
|
+
http.POST,
|
|
385
|
+
`/user/apps/appDefinitions/register${
|
|
386
|
+
detached ? '?detached=1' : ''
|
|
387
|
+
}`,
|
|
388
|
+
{
|
|
389
|
+
appName,
|
|
390
|
+
projectId,
|
|
391
|
+
hasPersistentData,
|
|
392
|
+
}
|
|
393
|
+
)
|
|
394
|
+
)
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
deleteApp(
|
|
398
|
+
appName: string | undefined,
|
|
399
|
+
volumes: string[],
|
|
400
|
+
appNames: string[] | undefined
|
|
401
|
+
): Promise<AppDeleteResponse> {
|
|
402
|
+
const http = this.http
|
|
403
|
+
|
|
404
|
+
return Promise.resolve() //
|
|
405
|
+
.then(
|
|
406
|
+
http.fetch(http.POST, '/user/apps/appDefinitions/delete', {
|
|
407
|
+
appName,
|
|
408
|
+
volumes,
|
|
409
|
+
appNames,
|
|
410
|
+
})
|
|
411
|
+
)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
deleteProjects(projectIds: string[]): Promise<void> {
|
|
415
|
+
const http = this.http
|
|
416
|
+
|
|
417
|
+
return Promise.resolve() //
|
|
418
|
+
.then(
|
|
419
|
+
http.fetch(http.POST, '/user/projects/delete', {
|
|
420
|
+
projectIds,
|
|
421
|
+
})
|
|
422
|
+
)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
enableSslForBaseDomain(appName: string): Promise<void> {
|
|
426
|
+
const http = this.http
|
|
427
|
+
|
|
428
|
+
return Promise.resolve() //
|
|
429
|
+
.then(
|
|
430
|
+
http.fetch(
|
|
431
|
+
http.POST,
|
|
432
|
+
'/user/apps/appDefinitions/enablebasedomainssl',
|
|
433
|
+
{
|
|
434
|
+
appName,
|
|
435
|
+
}
|
|
436
|
+
)
|
|
437
|
+
)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
attachNewCustomDomainToApp(
|
|
441
|
+
appName: string,
|
|
442
|
+
customDomain: string
|
|
443
|
+
): Promise<void> {
|
|
444
|
+
const http = this.http
|
|
445
|
+
|
|
446
|
+
return Promise.resolve() //
|
|
447
|
+
.then(
|
|
448
|
+
http.fetch(
|
|
449
|
+
http.POST,
|
|
450
|
+
'/user/apps/appDefinitions/customdomain',
|
|
451
|
+
{
|
|
452
|
+
appName,
|
|
453
|
+
customDomain,
|
|
454
|
+
}
|
|
455
|
+
)
|
|
456
|
+
)
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
enableSslForCustomDomain(
|
|
460
|
+
appName: string,
|
|
461
|
+
customDomain: string
|
|
462
|
+
): Promise<void> {
|
|
463
|
+
const http = this.http
|
|
464
|
+
|
|
465
|
+
return Promise.resolve() //
|
|
466
|
+
.then(
|
|
467
|
+
http.fetch(
|
|
468
|
+
http.POST,
|
|
469
|
+
'/user/apps/appDefinitions/enablecustomdomainssl',
|
|
470
|
+
{
|
|
471
|
+
appName,
|
|
472
|
+
customDomain,
|
|
473
|
+
}
|
|
474
|
+
)
|
|
475
|
+
)
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
removeCustomDomain(appName: string, customDomain: string): Promise<void> {
|
|
479
|
+
const http = this.http
|
|
480
|
+
|
|
481
|
+
return Promise.resolve() //
|
|
482
|
+
.then(
|
|
483
|
+
http.fetch(
|
|
484
|
+
http.POST,
|
|
485
|
+
'/user/apps/appDefinitions/removecustomdomain',
|
|
486
|
+
{
|
|
487
|
+
appName,
|
|
488
|
+
customDomain,
|
|
489
|
+
}
|
|
490
|
+
)
|
|
491
|
+
)
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
getLoadBalancerInfo(): Promise<LoadBalancerInfo> {
|
|
495
|
+
const http = this.http
|
|
496
|
+
|
|
497
|
+
return Promise.resolve() //
|
|
498
|
+
.then(http.fetch(http.GET, '/user/system/loadbalancerinfo', {}))
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
getNetDataInfo(): Promise<NetDataInfo> {
|
|
502
|
+
const http = this.http
|
|
503
|
+
|
|
504
|
+
return Promise.resolve() //
|
|
505
|
+
.then(http.fetch(http.GET, '/user/system/netdata', {}))
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
updateNetDataInfo(netDataInfo: NetDataInfo): Promise<void> {
|
|
509
|
+
const http = this.http
|
|
510
|
+
|
|
511
|
+
return Promise.resolve() //
|
|
512
|
+
.then(
|
|
513
|
+
http.fetch(http.POST, '/user/system/netdata', { netDataInfo })
|
|
514
|
+
)
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
getGoAccessInfo(): Promise<IGoAccessInfo> {
|
|
518
|
+
const http = this.http
|
|
519
|
+
|
|
520
|
+
return Promise.resolve() //
|
|
521
|
+
.then(http.fetch(http.GET, '/user/system/goaccess', {}))
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
updateGoAccessInfo(goAccessInfo: GoAccessInfo): Promise<void> {
|
|
525
|
+
const http = this.http
|
|
526
|
+
|
|
527
|
+
return Promise.resolve() //
|
|
528
|
+
.then(
|
|
529
|
+
http.fetch(http.POST, '/user/system/goaccess', { goAccessInfo })
|
|
530
|
+
)
|
|
531
|
+
}
|
|
532
|
+
getGoAccessReports(appName: string): Promise<GoAccessReportResponse[]> {
|
|
533
|
+
const http = this.http
|
|
534
|
+
|
|
535
|
+
return Promise.resolve() //
|
|
536
|
+
.then(
|
|
537
|
+
http.fetch(
|
|
538
|
+
http.GET,
|
|
539
|
+
`/user/system/goaccess/${appName}/files`,
|
|
540
|
+
{}
|
|
541
|
+
)
|
|
542
|
+
)
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
getGoAccessReport(reportUrl: string): Promise<string> {
|
|
546
|
+
const http = this.http
|
|
547
|
+
|
|
548
|
+
return Promise.resolve() //
|
|
549
|
+
.then(http.fetch(http.GET, reportUrl, {}))
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
changePass(oldPassword: string, newPassword: string): Promise<void> {
|
|
553
|
+
const http = this.http
|
|
554
|
+
|
|
555
|
+
return Promise.resolve() //
|
|
556
|
+
.then(
|
|
557
|
+
http.fetch(http.POST, '/user/changepassword', {
|
|
558
|
+
oldPassword,
|
|
559
|
+
newPassword,
|
|
560
|
+
})
|
|
561
|
+
)
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
getVersionInfo(): Promise<IVersionInfo> {
|
|
565
|
+
const http = this.http
|
|
566
|
+
|
|
567
|
+
return Promise.resolve() //
|
|
568
|
+
.then(http.fetch(http.GET, '/user/system/versioninfo', {}))
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
createBackup(): Promise<{ downloadToken: string }> {
|
|
572
|
+
const http = this.http
|
|
573
|
+
|
|
574
|
+
return Promise.resolve() //
|
|
575
|
+
.then(
|
|
576
|
+
http.fetch(http.POST, '/user/system/createbackup', {
|
|
577
|
+
postDownloadFileName: 'backup.tar',
|
|
578
|
+
})
|
|
579
|
+
)
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
performUpdate(latestVersion: string): Promise<void> {
|
|
583
|
+
const http = this.http
|
|
584
|
+
|
|
585
|
+
return Promise.resolve() //
|
|
586
|
+
.then(
|
|
587
|
+
http.fetch(http.POST, '/user/system/versioninfo', {
|
|
588
|
+
latestVersion,
|
|
589
|
+
})
|
|
590
|
+
)
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
getNginxConfig(): Promise<NginxConfig> {
|
|
594
|
+
const http = this.http
|
|
595
|
+
|
|
596
|
+
return Promise.resolve() //
|
|
597
|
+
.then(http.fetch(http.GET, '/user/system/nginxconfig', {}))
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
setNginxConfig(customBase: string, customCaptain: string): Promise<void> {
|
|
601
|
+
const http = this.http
|
|
602
|
+
|
|
603
|
+
return Promise.resolve() //
|
|
604
|
+
.then(
|
|
605
|
+
http.fetch(http.POST, '/user/system/nginxconfig', {
|
|
606
|
+
baseConfig: { customValue: customBase },
|
|
607
|
+
captainConfig: { customValue: customCaptain },
|
|
608
|
+
})
|
|
609
|
+
)
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
getUnusedImages(mostRecentLimit: number): Promise<UnusedImagesResponse> {
|
|
613
|
+
const http = this.http
|
|
614
|
+
return Promise.resolve() //
|
|
615
|
+
.then(
|
|
616
|
+
http.fetch(http.GET, '/user/apps/appDefinitions/unusedImages', {
|
|
617
|
+
mostRecentLimit: mostRecentLimit + '',
|
|
618
|
+
})
|
|
619
|
+
)
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
deleteImages(imageIds: string[]): Promise<void> {
|
|
623
|
+
const http = this.http
|
|
624
|
+
|
|
625
|
+
return Promise.resolve() //
|
|
626
|
+
.then(
|
|
627
|
+
http.fetch(
|
|
628
|
+
http.POST,
|
|
629
|
+
'/user/apps/appDefinitions/deleteImages',
|
|
630
|
+
{
|
|
631
|
+
imageIds,
|
|
632
|
+
}
|
|
633
|
+
)
|
|
634
|
+
)
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
getDiskCleanUpSettings(): Promise<IAutomatedCleanupConfigs> {
|
|
638
|
+
const http = this.http
|
|
639
|
+
|
|
640
|
+
return Promise.resolve() //
|
|
641
|
+
.then(http.fetch(http.GET, '/user/system/diskcleanup', {}))
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
setDiskCleanUpSettings(
|
|
645
|
+
mostRecentLimit: number,
|
|
646
|
+
cronSchedule: string,
|
|
647
|
+
timezone: string
|
|
648
|
+
): Promise<void> {
|
|
649
|
+
const http = this.http
|
|
650
|
+
|
|
651
|
+
return Promise.resolve() //
|
|
652
|
+
.then(
|
|
653
|
+
http.fetch(http.POST, '/user/system/diskcleanup', {
|
|
654
|
+
mostRecentLimit,
|
|
655
|
+
cronSchedule,
|
|
656
|
+
timezone,
|
|
657
|
+
})
|
|
658
|
+
)
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
getDockerRegistries(): Promise<RegistriesResponse> {
|
|
662
|
+
const http = this.http
|
|
663
|
+
|
|
664
|
+
return Promise.resolve() //
|
|
665
|
+
.then(http.fetch(http.GET, '/user/registries', {}))
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
enableSelfHostedDockerRegistry(): Promise<void> {
|
|
669
|
+
const http = this.http
|
|
670
|
+
|
|
671
|
+
return Promise.resolve() //
|
|
672
|
+
.then(
|
|
673
|
+
http.fetch(
|
|
674
|
+
http.POST,
|
|
675
|
+
'/user/system/selfhostregistry/enableregistry',
|
|
676
|
+
{}
|
|
677
|
+
)
|
|
678
|
+
)
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
disableSelfHostedDockerRegistry(): Promise<void> {
|
|
682
|
+
const http = this.http
|
|
683
|
+
|
|
684
|
+
return Promise.resolve() //
|
|
685
|
+
.then(
|
|
686
|
+
http.fetch(
|
|
687
|
+
http.POST,
|
|
688
|
+
'/user/system/selfhostregistry/disableregistry',
|
|
689
|
+
{}
|
|
690
|
+
)
|
|
691
|
+
)
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
addDockerRegistry(dockerRegistry: IRegistryInfo): Promise<void> {
|
|
695
|
+
const http = this.http
|
|
696
|
+
|
|
697
|
+
return Promise.resolve() //
|
|
698
|
+
.then(
|
|
699
|
+
http.fetch(http.POST, '/user/registries/insert', {
|
|
700
|
+
...dockerRegistry,
|
|
701
|
+
})
|
|
702
|
+
)
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
updateDockerRegistry(dockerRegistry: IRegistryInfo): Promise<void> {
|
|
706
|
+
const http = this.http
|
|
707
|
+
|
|
708
|
+
return Promise.resolve() //
|
|
709
|
+
.then(
|
|
710
|
+
http.fetch(http.POST, '/user/registries/update', {
|
|
711
|
+
...dockerRegistry,
|
|
712
|
+
})
|
|
713
|
+
)
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
deleteDockerRegistry(registryId: string): Promise<void> {
|
|
717
|
+
const http = this.http
|
|
718
|
+
|
|
719
|
+
return Promise.resolve() //
|
|
720
|
+
.then(
|
|
721
|
+
http.fetch(http.POST, '/user/registries/delete', {
|
|
722
|
+
registryId,
|
|
723
|
+
})
|
|
724
|
+
)
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
setDefaultPushDockerRegistry(registryId: string): Promise<void> {
|
|
728
|
+
const http = this.http
|
|
729
|
+
|
|
730
|
+
return Promise.resolve() //
|
|
731
|
+
.then(
|
|
732
|
+
http.fetch(http.POST, '/user/registries/setpush', {
|
|
733
|
+
registryId,
|
|
734
|
+
})
|
|
735
|
+
)
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
forceBuild(webhookPath: string): Promise<void> {
|
|
739
|
+
const http = this.http
|
|
740
|
+
|
|
741
|
+
return Promise.resolve() //
|
|
742
|
+
.then(http.fetch(http.POST, webhookPath, {}))
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
getAllNodes(): Promise<{ nodes: ServerDockerInfo[] }> {
|
|
746
|
+
const http = this.http
|
|
747
|
+
|
|
748
|
+
return Promise.resolve() //
|
|
749
|
+
.then(http.fetch(http.GET, '/user/system/nodes', {}))
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
getAllOneClickApps(): Promise<OneClickAppResponse> {
|
|
753
|
+
const http = this.http
|
|
754
|
+
|
|
755
|
+
return Promise.resolve() //
|
|
756
|
+
.then(http.fetch(http.GET, '/user/oneclick/template/list', {}))
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
getOneClickAppByName(
|
|
760
|
+
appName: string,
|
|
761
|
+
baseDomain: string
|
|
762
|
+
): Promise<OneClickAppDefinitionResponse> {
|
|
763
|
+
const http = this.http
|
|
764
|
+
|
|
765
|
+
return Promise.resolve() //
|
|
766
|
+
.then(
|
|
767
|
+
http.fetch(http.GET, '/user/oneclick/template/app', {
|
|
768
|
+
appName,
|
|
769
|
+
baseDomain,
|
|
770
|
+
})
|
|
771
|
+
)
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
getAllOneClickAppRepos(): Promise<OneClickAppRepositories> {
|
|
775
|
+
const http = this.http
|
|
776
|
+
|
|
777
|
+
return Promise.resolve() //
|
|
778
|
+
.then(http.fetch(http.GET, '/user/oneclick/repositories', {}))
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
addNewCustomOneClickRepo(repositoryUrl: string): Promise<void> {
|
|
782
|
+
const http = this.http
|
|
783
|
+
|
|
784
|
+
return Promise.resolve() //
|
|
785
|
+
.then(
|
|
786
|
+
http.fetch(http.POST, '/user/oneclick/repositories/insert', {
|
|
787
|
+
repositoryUrl,
|
|
788
|
+
})
|
|
789
|
+
)
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
deleteCustomOneClickRepo(repositoryUrl: string): Promise<void> {
|
|
793
|
+
const http = this.http
|
|
794
|
+
|
|
795
|
+
return Promise.resolve() //
|
|
796
|
+
.then(
|
|
797
|
+
http.fetch(http.POST, '/user/oneclick/repositories/delete', {
|
|
798
|
+
repositoryUrl,
|
|
799
|
+
})
|
|
800
|
+
)
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
addDockerNode(
|
|
804
|
+
nodeType: string,
|
|
805
|
+
privateKey: string,
|
|
806
|
+
remoteNodeIpAddress: string,
|
|
807
|
+
sshPort: string,
|
|
808
|
+
sshUser: string,
|
|
809
|
+
captainIpAddress: string
|
|
810
|
+
): Promise<void> {
|
|
811
|
+
const http = this.http
|
|
812
|
+
|
|
813
|
+
return Promise.resolve() //
|
|
814
|
+
.then(
|
|
815
|
+
http.fetch(http.POST, '/user/system/nodes', {
|
|
816
|
+
nodeType,
|
|
817
|
+
privateKey,
|
|
818
|
+
remoteNodeIpAddress,
|
|
819
|
+
sshPort,
|
|
820
|
+
sshUser,
|
|
821
|
+
captainIpAddress,
|
|
822
|
+
})
|
|
823
|
+
)
|
|
824
|
+
}
|
|
825
|
+
}
|