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
package/.prettierrc.json
ADDED
package/.yarnrc.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodeLinker: node-modules
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# CapRover API SDK (TypeScript)
|
|
2
|
+
|
|
3
|
+
A simple, typed TypeScript SDK for the CapRover API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
npm install caprover-api
|
|
8
|
+
|
|
9
|
+
csharp
|
|
10
|
+
Copy
|
|
11
|
+
Edit
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import CapRoverAPI, { CapRoverModels } from 'caprover-api'
|
|
17
|
+
|
|
18
|
+
const caprover = new CapRoverAPI(
|
|
19
|
+
'https://captain.server.demo.caprover.com',
|
|
20
|
+
() => {
|
|
21
|
+
// get password and otp from user
|
|
22
|
+
return Promise.resolve({
|
|
23
|
+
password: 'captain42',
|
|
24
|
+
otpToken: undefined, // only if 2FA is enabled
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
caprover
|
|
30
|
+
.getAllNodes()
|
|
31
|
+
.then((response) => {
|
|
32
|
+
console.log(response)
|
|
33
|
+
})
|
|
34
|
+
.catch((error) => {
|
|
35
|
+
console.log(error)
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## **How to Run Locally**
|
|
42
|
+
|
|
43
|
+
1. `npm install`
|
|
44
|
+
2. `npm run dev` _(after putting your own password/URL!)_
|
|
@@ -0,0 +1,114 @@
|
|
|
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 { IProConfig, IProFeatures, TwoFactorAuthRequest, TwoFactorAuthResponse } from '../models/IProFeatures';
|
|
13
|
+
import { IRegistryInfo } from '../models/IRegistryInfo';
|
|
14
|
+
import { IVersionInfo } from '../models/IVersionInfo';
|
|
15
|
+
import LoadBalancerInfo from '../models/LoadBalancerInfo';
|
|
16
|
+
import LogsResponse from '../models/LogsResponse';
|
|
17
|
+
import { NetDataInfo } from '../models/NetDataInfo';
|
|
18
|
+
import NginxConfig from '../models/NginxConfig';
|
|
19
|
+
import OneClickAppDefinitionResponse from '../models/OneClickAppDefinitionResponse';
|
|
20
|
+
import OneClickAppRepositories from '../models/OneClickAppRepositories';
|
|
21
|
+
import OneClickAppResponse from '../models/OneClickAppResponse';
|
|
22
|
+
import { ProjectDefinition } from '../models/ProjectDefinition';
|
|
23
|
+
import ProjectsResponse from '../models/ProjectsResponse';
|
|
24
|
+
import RegistriesResponse from '../models/RegistriesResponse';
|
|
25
|
+
import { ServerDockerInfo } from '../models/ServerDockerInfo';
|
|
26
|
+
import UnusedImagesResponse from '../models/UnusedImagesResponse';
|
|
27
|
+
export type AuthenticationContent = {
|
|
28
|
+
password: string;
|
|
29
|
+
otpToken?: string;
|
|
30
|
+
};
|
|
31
|
+
export type AuthRequiredCallback = () => Promise<AuthenticationContent>;
|
|
32
|
+
export default class ApiManager {
|
|
33
|
+
private authCallback;
|
|
34
|
+
private http;
|
|
35
|
+
constructor(baseDomain: string, authCallback: AuthRequiredCallback);
|
|
36
|
+
destroy(): void;
|
|
37
|
+
getAuthToken(): Promise<string>;
|
|
38
|
+
getAllThemes(): Promise<{
|
|
39
|
+
themes: CapRoverTheme[] | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
getCurrentTheme(): Promise<{
|
|
42
|
+
theme: CapRoverTheme;
|
|
43
|
+
}>;
|
|
44
|
+
setCurrentTheme(themeName: string): Promise<{}>;
|
|
45
|
+
saveTheme(oldName: string, theme: CapRoverTheme): Promise<{}>;
|
|
46
|
+
deleteTheme(themeName: string): Promise<{}>;
|
|
47
|
+
getProFeaturesState(): Promise<{
|
|
48
|
+
proFeaturesState: IProFeatures;
|
|
49
|
+
}>;
|
|
50
|
+
setProApiKey(apiKey: string): Promise<void>;
|
|
51
|
+
getProConfigs(): Promise<{
|
|
52
|
+
proConfigs: IProConfig;
|
|
53
|
+
}>;
|
|
54
|
+
setProConfigs(data: IProConfig): Promise<void>;
|
|
55
|
+
getOtpStatus(): Promise<TwoFactorAuthResponse>;
|
|
56
|
+
setOtpStatus(data: TwoFactorAuthRequest): Promise<TwoFactorAuthResponse>;
|
|
57
|
+
getCaptainInfo(): Promise<CaptainInfo>;
|
|
58
|
+
updateRootDomain(rootDomain: string, force: boolean): Promise<void>;
|
|
59
|
+
enableRootSsl(emailAddress: string): Promise<void>;
|
|
60
|
+
forceSsl(isEnabled: boolean): Promise<void>;
|
|
61
|
+
getAllApps(): Promise<AppDefinitionsResponse>;
|
|
62
|
+
getAllProjects(): Promise<ProjectsResponse>;
|
|
63
|
+
fetchBuildLogs(appName: string): Promise<BuildLogsResponse>;
|
|
64
|
+
fetchAppLogsInHex(appName: string): Promise<LogsResponse>;
|
|
65
|
+
uploadAppData(appName: string, file: File): Promise<void>;
|
|
66
|
+
registerProject(selectedProject: ProjectDefinition): Promise<ProjectDefinition>;
|
|
67
|
+
updateProject(project: ProjectDefinition): Promise<void>;
|
|
68
|
+
uploadCaptainDefinitionContent(appName: string, captainDefinition: ICaptainDefinition, gitHash: string, detached: boolean): Promise<void>;
|
|
69
|
+
updateConfigAndSave(appName: string, appDefinition: IAppDef): Promise<void>;
|
|
70
|
+
renameApp(oldAppName: string, newAppName: string): Promise<void>;
|
|
71
|
+
registerNewApp(appName: string, projectId: string, hasPersistentData: boolean, detached: boolean): Promise<void>;
|
|
72
|
+
deleteApp(appName: string | undefined, volumes: string[], appNames: string[] | undefined): Promise<AppDeleteResponse>;
|
|
73
|
+
deleteProjects(projectIds: string[]): Promise<void>;
|
|
74
|
+
enableSslForBaseDomain(appName: string): Promise<void>;
|
|
75
|
+
attachNewCustomDomainToApp(appName: string, customDomain: string): Promise<void>;
|
|
76
|
+
enableSslForCustomDomain(appName: string, customDomain: string): Promise<void>;
|
|
77
|
+
removeCustomDomain(appName: string, customDomain: string): Promise<void>;
|
|
78
|
+
getLoadBalancerInfo(): Promise<LoadBalancerInfo>;
|
|
79
|
+
getNetDataInfo(): Promise<NetDataInfo>;
|
|
80
|
+
updateNetDataInfo(netDataInfo: NetDataInfo): Promise<void>;
|
|
81
|
+
getGoAccessInfo(): Promise<IGoAccessInfo>;
|
|
82
|
+
updateGoAccessInfo(goAccessInfo: GoAccessInfo): Promise<void>;
|
|
83
|
+
getGoAccessReports(appName: string): Promise<GoAccessReportResponse[]>;
|
|
84
|
+
getGoAccessReport(reportUrl: string): Promise<string>;
|
|
85
|
+
changePass(oldPassword: string, newPassword: string): Promise<void>;
|
|
86
|
+
getVersionInfo(): Promise<IVersionInfo>;
|
|
87
|
+
createBackup(): Promise<{
|
|
88
|
+
downloadToken: string;
|
|
89
|
+
}>;
|
|
90
|
+
performUpdate(latestVersion: string): Promise<void>;
|
|
91
|
+
getNginxConfig(): Promise<NginxConfig>;
|
|
92
|
+
setNginxConfig(customBase: string, customCaptain: string): Promise<void>;
|
|
93
|
+
getUnusedImages(mostRecentLimit: number): Promise<UnusedImagesResponse>;
|
|
94
|
+
deleteImages(imageIds: string[]): Promise<void>;
|
|
95
|
+
getDiskCleanUpSettings(): Promise<IAutomatedCleanupConfigs>;
|
|
96
|
+
setDiskCleanUpSettings(mostRecentLimit: number, cronSchedule: string, timezone: string): Promise<void>;
|
|
97
|
+
getDockerRegistries(): Promise<RegistriesResponse>;
|
|
98
|
+
enableSelfHostedDockerRegistry(): Promise<void>;
|
|
99
|
+
disableSelfHostedDockerRegistry(): Promise<void>;
|
|
100
|
+
addDockerRegistry(dockerRegistry: IRegistryInfo): Promise<void>;
|
|
101
|
+
updateDockerRegistry(dockerRegistry: IRegistryInfo): Promise<void>;
|
|
102
|
+
deleteDockerRegistry(registryId: string): Promise<void>;
|
|
103
|
+
setDefaultPushDockerRegistry(registryId: string): Promise<void>;
|
|
104
|
+
forceBuild(webhookPath: string): Promise<void>;
|
|
105
|
+
getAllNodes(): Promise<{
|
|
106
|
+
nodes: ServerDockerInfo[];
|
|
107
|
+
}>;
|
|
108
|
+
getAllOneClickApps(): Promise<OneClickAppResponse>;
|
|
109
|
+
getOneClickAppByName(appName: string, baseDomain: string): Promise<OneClickAppDefinitionResponse>;
|
|
110
|
+
getAllOneClickAppRepos(): Promise<OneClickAppRepositories>;
|
|
111
|
+
addNewCustomOneClickRepo(repositoryUrl: string): Promise<void>;
|
|
112
|
+
deleteCustomOneClickRepo(repositoryUrl: string): Promise<void>;
|
|
113
|
+
addDockerNode(nodeType: string, privateKey: string, remoteNodeIpAddress: string, sshPort: string, sshUser: string, captainIpAddress: string): Promise<void>;
|
|
114
|
+
}
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const HttpClient_1 = __importDefault(require("./HttpClient"));
|
|
7
|
+
class ApiManager {
|
|
8
|
+
constructor(baseDomain, authCallback) {
|
|
9
|
+
this.authCallback = authCallback;
|
|
10
|
+
const self = this;
|
|
11
|
+
const URL = baseDomain + '/api/v2';
|
|
12
|
+
this.http = new HttpClient_1.default(URL, function () {
|
|
13
|
+
return self.getAuthToken();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
destroy() {
|
|
17
|
+
this.http.destroy();
|
|
18
|
+
}
|
|
19
|
+
getAuthToken() {
|
|
20
|
+
const self = this;
|
|
21
|
+
const http = self.http;
|
|
22
|
+
return Promise.resolve() //
|
|
23
|
+
.then(() => {
|
|
24
|
+
return self.authCallback();
|
|
25
|
+
})
|
|
26
|
+
.then((authContent) => {
|
|
27
|
+
return Promise.resolve() //
|
|
28
|
+
.then(http.fetch(http.POST, '/login', {
|
|
29
|
+
password: authContent?.password,
|
|
30
|
+
otpToken: authContent?.otpToken,
|
|
31
|
+
}));
|
|
32
|
+
})
|
|
33
|
+
.then(function (data) {
|
|
34
|
+
return data.token;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getAllThemes() {
|
|
38
|
+
const http = this.http;
|
|
39
|
+
return Promise.resolve() //
|
|
40
|
+
.then(http.fetch(http.GET, '/user/system/themes/all', {}));
|
|
41
|
+
}
|
|
42
|
+
getCurrentTheme() {
|
|
43
|
+
const http = this.http;
|
|
44
|
+
return Promise.resolve() //
|
|
45
|
+
.then(http.fetch(http.GET, '/theme/current', {}));
|
|
46
|
+
}
|
|
47
|
+
setCurrentTheme(themeName) {
|
|
48
|
+
const http = this.http;
|
|
49
|
+
return Promise.resolve() //
|
|
50
|
+
.then(http.fetch(http.POST, '/user/system/themes/setcurrent', {
|
|
51
|
+
themeName,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
saveTheme(oldName, theme) {
|
|
55
|
+
const http = this.http;
|
|
56
|
+
return Promise.resolve() //
|
|
57
|
+
.then(http.fetch(http.POST, '/user/system/themes/update', {
|
|
58
|
+
oldName,
|
|
59
|
+
name: theme.name,
|
|
60
|
+
content: theme.content,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
deleteTheme(themeName) {
|
|
64
|
+
const http = this.http;
|
|
65
|
+
return Promise.resolve() //
|
|
66
|
+
.then(http.fetch(http.POST, '/user/system/themes/delete', {
|
|
67
|
+
themeName,
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
getProFeaturesState() {
|
|
71
|
+
const http = this.http;
|
|
72
|
+
return Promise.resolve() //
|
|
73
|
+
.then(http.fetch(http.GET, '/user/pro/state', {}));
|
|
74
|
+
}
|
|
75
|
+
setProApiKey(apiKey) {
|
|
76
|
+
const http = this.http;
|
|
77
|
+
return Promise.resolve() //
|
|
78
|
+
.then(http.fetch(http.POST, '/user/pro/apikey', { apiKey: apiKey }));
|
|
79
|
+
}
|
|
80
|
+
getProConfigs() {
|
|
81
|
+
const http = this.http;
|
|
82
|
+
return Promise.resolve() //
|
|
83
|
+
.then(http.fetch(http.GET, '/user/pro/configs', {}));
|
|
84
|
+
}
|
|
85
|
+
setProConfigs(data) {
|
|
86
|
+
const http = this.http;
|
|
87
|
+
return Promise.resolve() //
|
|
88
|
+
.then(http.fetch(http.POST, '/user/pro/configs', { proConfigs: data }));
|
|
89
|
+
}
|
|
90
|
+
getOtpStatus() {
|
|
91
|
+
const http = this.http;
|
|
92
|
+
return Promise.resolve() //
|
|
93
|
+
.then(http.fetch(http.GET, '/user/pro/otp', {}));
|
|
94
|
+
}
|
|
95
|
+
setOtpStatus(data) {
|
|
96
|
+
const http = this.http;
|
|
97
|
+
return Promise.resolve() //
|
|
98
|
+
.then(http.fetch(http.POST, '/user/pro/otp', data));
|
|
99
|
+
}
|
|
100
|
+
getCaptainInfo() {
|
|
101
|
+
const http = this.http;
|
|
102
|
+
return Promise.resolve() //
|
|
103
|
+
.then(http.fetch(http.GET, '/user/system/info', {}));
|
|
104
|
+
}
|
|
105
|
+
updateRootDomain(rootDomain, force) {
|
|
106
|
+
const http = this.http;
|
|
107
|
+
return Promise.resolve() //
|
|
108
|
+
.then(http.fetch(http.POST, '/user/system/changerootdomain', {
|
|
109
|
+
rootDomain,
|
|
110
|
+
force,
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
enableRootSsl(emailAddress) {
|
|
114
|
+
const http = this.http;
|
|
115
|
+
return Promise.resolve() //
|
|
116
|
+
.then(http.fetch(http.POST, '/user/system/enablessl', {
|
|
117
|
+
emailAddress,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
forceSsl(isEnabled) {
|
|
121
|
+
const http = this.http;
|
|
122
|
+
return Promise.resolve() //
|
|
123
|
+
.then(http.fetch(http.POST, '/user/system/forcessl', { isEnabled }));
|
|
124
|
+
}
|
|
125
|
+
getAllApps() {
|
|
126
|
+
const http = this.http;
|
|
127
|
+
return Promise.resolve() //
|
|
128
|
+
.then(http.fetch(http.GET, '/user/apps/appDefinitions', {}));
|
|
129
|
+
}
|
|
130
|
+
getAllProjects() {
|
|
131
|
+
const http = this.http;
|
|
132
|
+
return Promise.resolve() //
|
|
133
|
+
.then(http.fetch(http.GET, '/user/projects', {}));
|
|
134
|
+
}
|
|
135
|
+
fetchBuildLogs(appName) {
|
|
136
|
+
const http = this.http;
|
|
137
|
+
return Promise.resolve() //
|
|
138
|
+
.then(http.fetch(http.GET, `/user/apps/appData/${appName}`, {}));
|
|
139
|
+
}
|
|
140
|
+
fetchAppLogsInHex(appName) {
|
|
141
|
+
const http = this.http;
|
|
142
|
+
return Promise.resolve() //
|
|
143
|
+
.then(http.fetch(http.GET, `/user/apps/appData/${appName}/logs?encoding=hex`, {}));
|
|
144
|
+
}
|
|
145
|
+
uploadAppData(appName, file) {
|
|
146
|
+
const http = this.http;
|
|
147
|
+
let formData = new FormData();
|
|
148
|
+
formData.append('sourceFile', file);
|
|
149
|
+
return Promise.resolve() //
|
|
150
|
+
.then(http.fetch(http.POST, `/user/apps/appData/${appName}?detached=1`, formData));
|
|
151
|
+
}
|
|
152
|
+
registerProject(selectedProject) {
|
|
153
|
+
const http = this.http;
|
|
154
|
+
return Promise.resolve() //
|
|
155
|
+
.then(http.fetch(http.POST, '/user/projects/register', {
|
|
156
|
+
...selectedProject,
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
updateProject(project) {
|
|
160
|
+
const http = this.http;
|
|
161
|
+
return Promise.resolve() //
|
|
162
|
+
.then(http.fetch(http.POST, '/user/projects/update', {
|
|
163
|
+
projectDefinition: project,
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
uploadCaptainDefinitionContent(appName, captainDefinition, gitHash, detached) {
|
|
167
|
+
const http = this.http;
|
|
168
|
+
return Promise.resolve() //
|
|
169
|
+
.then(http.fetch(http.POST, `/user/apps/appData/${appName}${detached ? '?detached=1' : ''}`, {
|
|
170
|
+
captainDefinitionContent: JSON.stringify(captainDefinition),
|
|
171
|
+
gitHash,
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
updateConfigAndSave(appName, appDefinition) {
|
|
175
|
+
let instanceCount = appDefinition.instanceCount;
|
|
176
|
+
let captainDefinitionRelativeFilePath = appDefinition.captainDefinitionRelativeFilePath;
|
|
177
|
+
let envVars = appDefinition.envVars;
|
|
178
|
+
let notExposeAsWebApp = appDefinition.notExposeAsWebApp;
|
|
179
|
+
let forceSsl = appDefinition.forceSsl;
|
|
180
|
+
let websocketSupport = appDefinition.websocketSupport;
|
|
181
|
+
let volumes = appDefinition.volumes;
|
|
182
|
+
let ports = appDefinition.ports;
|
|
183
|
+
let nodeId = appDefinition.nodeId;
|
|
184
|
+
let appPushWebhook = appDefinition.appPushWebhook;
|
|
185
|
+
let customNginxConfig = appDefinition.customNginxConfig;
|
|
186
|
+
let preDeployFunction = appDefinition.preDeployFunction;
|
|
187
|
+
let serviceUpdateOverride = appDefinition.serviceUpdateOverride;
|
|
188
|
+
let containerHttpPort = appDefinition.containerHttpPort;
|
|
189
|
+
let description = appDefinition.description;
|
|
190
|
+
let httpAuth = appDefinition.httpAuth;
|
|
191
|
+
let appDeployTokenConfig = appDefinition.appDeployTokenConfig;
|
|
192
|
+
let tags = appDefinition.tags;
|
|
193
|
+
let redirectDomain = appDefinition.redirectDomain;
|
|
194
|
+
let projectId = appDefinition.projectId;
|
|
195
|
+
const http = this.http;
|
|
196
|
+
return Promise.resolve() //
|
|
197
|
+
.then(http.fetch(http.POST, '/user/apps/appDefinitions/update', {
|
|
198
|
+
appName: appName,
|
|
199
|
+
instanceCount: instanceCount,
|
|
200
|
+
captainDefinitionRelativeFilePath: captainDefinitionRelativeFilePath,
|
|
201
|
+
notExposeAsWebApp: notExposeAsWebApp,
|
|
202
|
+
forceSsl: forceSsl,
|
|
203
|
+
websocketSupport: websocketSupport,
|
|
204
|
+
volumes: volumes,
|
|
205
|
+
ports: ports,
|
|
206
|
+
customNginxConfig: customNginxConfig,
|
|
207
|
+
appPushWebhook: appPushWebhook,
|
|
208
|
+
nodeId: nodeId,
|
|
209
|
+
preDeployFunction: preDeployFunction,
|
|
210
|
+
serviceUpdateOverride: serviceUpdateOverride,
|
|
211
|
+
containerHttpPort: containerHttpPort,
|
|
212
|
+
description: description,
|
|
213
|
+
httpAuth: httpAuth,
|
|
214
|
+
envVars: envVars,
|
|
215
|
+
appDeployTokenConfig: appDeployTokenConfig,
|
|
216
|
+
tags: tags,
|
|
217
|
+
redirectDomain: redirectDomain,
|
|
218
|
+
projectId: projectId,
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
renameApp(oldAppName, newAppName) {
|
|
222
|
+
const http = this.http;
|
|
223
|
+
return Promise.resolve() //
|
|
224
|
+
.then(http.fetch(http.POST, '/user/apps/appDefinitions/rename', {
|
|
225
|
+
oldAppName,
|
|
226
|
+
newAppName,
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
registerNewApp(appName, projectId, hasPersistentData, detached) {
|
|
230
|
+
const http = this.http;
|
|
231
|
+
return Promise.resolve() //
|
|
232
|
+
.then(http.fetch(http.POST, `/user/apps/appDefinitions/register${detached ? '?detached=1' : ''}`, {
|
|
233
|
+
appName,
|
|
234
|
+
projectId,
|
|
235
|
+
hasPersistentData,
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
deleteApp(appName, volumes, appNames) {
|
|
239
|
+
const http = this.http;
|
|
240
|
+
return Promise.resolve() //
|
|
241
|
+
.then(http.fetch(http.POST, '/user/apps/appDefinitions/delete', {
|
|
242
|
+
appName,
|
|
243
|
+
volumes,
|
|
244
|
+
appNames,
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
deleteProjects(projectIds) {
|
|
248
|
+
const http = this.http;
|
|
249
|
+
return Promise.resolve() //
|
|
250
|
+
.then(http.fetch(http.POST, '/user/projects/delete', {
|
|
251
|
+
projectIds,
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
enableSslForBaseDomain(appName) {
|
|
255
|
+
const http = this.http;
|
|
256
|
+
return Promise.resolve() //
|
|
257
|
+
.then(http.fetch(http.POST, '/user/apps/appDefinitions/enablebasedomainssl', {
|
|
258
|
+
appName,
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
attachNewCustomDomainToApp(appName, customDomain) {
|
|
262
|
+
const http = this.http;
|
|
263
|
+
return Promise.resolve() //
|
|
264
|
+
.then(http.fetch(http.POST, '/user/apps/appDefinitions/customdomain', {
|
|
265
|
+
appName,
|
|
266
|
+
customDomain,
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
enableSslForCustomDomain(appName, customDomain) {
|
|
270
|
+
const http = this.http;
|
|
271
|
+
return Promise.resolve() //
|
|
272
|
+
.then(http.fetch(http.POST, '/user/apps/appDefinitions/enablecustomdomainssl', {
|
|
273
|
+
appName,
|
|
274
|
+
customDomain,
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
removeCustomDomain(appName, customDomain) {
|
|
278
|
+
const http = this.http;
|
|
279
|
+
return Promise.resolve() //
|
|
280
|
+
.then(http.fetch(http.POST, '/user/apps/appDefinitions/removecustomdomain', {
|
|
281
|
+
appName,
|
|
282
|
+
customDomain,
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
getLoadBalancerInfo() {
|
|
286
|
+
const http = this.http;
|
|
287
|
+
return Promise.resolve() //
|
|
288
|
+
.then(http.fetch(http.GET, '/user/system/loadbalancerinfo', {}));
|
|
289
|
+
}
|
|
290
|
+
getNetDataInfo() {
|
|
291
|
+
const http = this.http;
|
|
292
|
+
return Promise.resolve() //
|
|
293
|
+
.then(http.fetch(http.GET, '/user/system/netdata', {}));
|
|
294
|
+
}
|
|
295
|
+
updateNetDataInfo(netDataInfo) {
|
|
296
|
+
const http = this.http;
|
|
297
|
+
return Promise.resolve() //
|
|
298
|
+
.then(http.fetch(http.POST, '/user/system/netdata', { netDataInfo }));
|
|
299
|
+
}
|
|
300
|
+
getGoAccessInfo() {
|
|
301
|
+
const http = this.http;
|
|
302
|
+
return Promise.resolve() //
|
|
303
|
+
.then(http.fetch(http.GET, '/user/system/goaccess', {}));
|
|
304
|
+
}
|
|
305
|
+
updateGoAccessInfo(goAccessInfo) {
|
|
306
|
+
const http = this.http;
|
|
307
|
+
return Promise.resolve() //
|
|
308
|
+
.then(http.fetch(http.POST, '/user/system/goaccess', { goAccessInfo }));
|
|
309
|
+
}
|
|
310
|
+
getGoAccessReports(appName) {
|
|
311
|
+
const http = this.http;
|
|
312
|
+
return Promise.resolve() //
|
|
313
|
+
.then(http.fetch(http.GET, `/user/system/goaccess/${appName}/files`, {}));
|
|
314
|
+
}
|
|
315
|
+
getGoAccessReport(reportUrl) {
|
|
316
|
+
const http = this.http;
|
|
317
|
+
return Promise.resolve() //
|
|
318
|
+
.then(http.fetch(http.GET, reportUrl, {}));
|
|
319
|
+
}
|
|
320
|
+
changePass(oldPassword, newPassword) {
|
|
321
|
+
const http = this.http;
|
|
322
|
+
return Promise.resolve() //
|
|
323
|
+
.then(http.fetch(http.POST, '/user/changepassword', {
|
|
324
|
+
oldPassword,
|
|
325
|
+
newPassword,
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
getVersionInfo() {
|
|
329
|
+
const http = this.http;
|
|
330
|
+
return Promise.resolve() //
|
|
331
|
+
.then(http.fetch(http.GET, '/user/system/versioninfo', {}));
|
|
332
|
+
}
|
|
333
|
+
createBackup() {
|
|
334
|
+
const http = this.http;
|
|
335
|
+
return Promise.resolve() //
|
|
336
|
+
.then(http.fetch(http.POST, '/user/system/createbackup', {
|
|
337
|
+
postDownloadFileName: 'backup.tar',
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
performUpdate(latestVersion) {
|
|
341
|
+
const http = this.http;
|
|
342
|
+
return Promise.resolve() //
|
|
343
|
+
.then(http.fetch(http.POST, '/user/system/versioninfo', {
|
|
344
|
+
latestVersion,
|
|
345
|
+
}));
|
|
346
|
+
}
|
|
347
|
+
getNginxConfig() {
|
|
348
|
+
const http = this.http;
|
|
349
|
+
return Promise.resolve() //
|
|
350
|
+
.then(http.fetch(http.GET, '/user/system/nginxconfig', {}));
|
|
351
|
+
}
|
|
352
|
+
setNginxConfig(customBase, customCaptain) {
|
|
353
|
+
const http = this.http;
|
|
354
|
+
return Promise.resolve() //
|
|
355
|
+
.then(http.fetch(http.POST, '/user/system/nginxconfig', {
|
|
356
|
+
baseConfig: { customValue: customBase },
|
|
357
|
+
captainConfig: { customValue: customCaptain },
|
|
358
|
+
}));
|
|
359
|
+
}
|
|
360
|
+
getUnusedImages(mostRecentLimit) {
|
|
361
|
+
const http = this.http;
|
|
362
|
+
return Promise.resolve() //
|
|
363
|
+
.then(http.fetch(http.GET, '/user/apps/appDefinitions/unusedImages', {
|
|
364
|
+
mostRecentLimit: mostRecentLimit + '',
|
|
365
|
+
}));
|
|
366
|
+
}
|
|
367
|
+
deleteImages(imageIds) {
|
|
368
|
+
const http = this.http;
|
|
369
|
+
return Promise.resolve() //
|
|
370
|
+
.then(http.fetch(http.POST, '/user/apps/appDefinitions/deleteImages', {
|
|
371
|
+
imageIds,
|
|
372
|
+
}));
|
|
373
|
+
}
|
|
374
|
+
getDiskCleanUpSettings() {
|
|
375
|
+
const http = this.http;
|
|
376
|
+
return Promise.resolve() //
|
|
377
|
+
.then(http.fetch(http.GET, '/user/system/diskcleanup', {}));
|
|
378
|
+
}
|
|
379
|
+
setDiskCleanUpSettings(mostRecentLimit, cronSchedule, timezone) {
|
|
380
|
+
const http = this.http;
|
|
381
|
+
return Promise.resolve() //
|
|
382
|
+
.then(http.fetch(http.POST, '/user/system/diskcleanup', {
|
|
383
|
+
mostRecentLimit,
|
|
384
|
+
cronSchedule,
|
|
385
|
+
timezone,
|
|
386
|
+
}));
|
|
387
|
+
}
|
|
388
|
+
getDockerRegistries() {
|
|
389
|
+
const http = this.http;
|
|
390
|
+
return Promise.resolve() //
|
|
391
|
+
.then(http.fetch(http.GET, '/user/registries', {}));
|
|
392
|
+
}
|
|
393
|
+
enableSelfHostedDockerRegistry() {
|
|
394
|
+
const http = this.http;
|
|
395
|
+
return Promise.resolve() //
|
|
396
|
+
.then(http.fetch(http.POST, '/user/system/selfhostregistry/enableregistry', {}));
|
|
397
|
+
}
|
|
398
|
+
disableSelfHostedDockerRegistry() {
|
|
399
|
+
const http = this.http;
|
|
400
|
+
return Promise.resolve() //
|
|
401
|
+
.then(http.fetch(http.POST, '/user/system/selfhostregistry/disableregistry', {}));
|
|
402
|
+
}
|
|
403
|
+
addDockerRegistry(dockerRegistry) {
|
|
404
|
+
const http = this.http;
|
|
405
|
+
return Promise.resolve() //
|
|
406
|
+
.then(http.fetch(http.POST, '/user/registries/insert', {
|
|
407
|
+
...dockerRegistry,
|
|
408
|
+
}));
|
|
409
|
+
}
|
|
410
|
+
updateDockerRegistry(dockerRegistry) {
|
|
411
|
+
const http = this.http;
|
|
412
|
+
return Promise.resolve() //
|
|
413
|
+
.then(http.fetch(http.POST, '/user/registries/update', {
|
|
414
|
+
...dockerRegistry,
|
|
415
|
+
}));
|
|
416
|
+
}
|
|
417
|
+
deleteDockerRegistry(registryId) {
|
|
418
|
+
const http = this.http;
|
|
419
|
+
return Promise.resolve() //
|
|
420
|
+
.then(http.fetch(http.POST, '/user/registries/delete', {
|
|
421
|
+
registryId,
|
|
422
|
+
}));
|
|
423
|
+
}
|
|
424
|
+
setDefaultPushDockerRegistry(registryId) {
|
|
425
|
+
const http = this.http;
|
|
426
|
+
return Promise.resolve() //
|
|
427
|
+
.then(http.fetch(http.POST, '/user/registries/setpush', {
|
|
428
|
+
registryId,
|
|
429
|
+
}));
|
|
430
|
+
}
|
|
431
|
+
forceBuild(webhookPath) {
|
|
432
|
+
const http = this.http;
|
|
433
|
+
return Promise.resolve() //
|
|
434
|
+
.then(http.fetch(http.POST, webhookPath, {}));
|
|
435
|
+
}
|
|
436
|
+
getAllNodes() {
|
|
437
|
+
const http = this.http;
|
|
438
|
+
return Promise.resolve() //
|
|
439
|
+
.then(http.fetch(http.GET, '/user/system/nodes', {}));
|
|
440
|
+
}
|
|
441
|
+
getAllOneClickApps() {
|
|
442
|
+
const http = this.http;
|
|
443
|
+
return Promise.resolve() //
|
|
444
|
+
.then(http.fetch(http.GET, '/user/oneclick/template/list', {}));
|
|
445
|
+
}
|
|
446
|
+
getOneClickAppByName(appName, baseDomain) {
|
|
447
|
+
const http = this.http;
|
|
448
|
+
return Promise.resolve() //
|
|
449
|
+
.then(http.fetch(http.GET, '/user/oneclick/template/app', {
|
|
450
|
+
appName,
|
|
451
|
+
baseDomain,
|
|
452
|
+
}));
|
|
453
|
+
}
|
|
454
|
+
getAllOneClickAppRepos() {
|
|
455
|
+
const http = this.http;
|
|
456
|
+
return Promise.resolve() //
|
|
457
|
+
.then(http.fetch(http.GET, '/user/oneclick/repositories', {}));
|
|
458
|
+
}
|
|
459
|
+
addNewCustomOneClickRepo(repositoryUrl) {
|
|
460
|
+
const http = this.http;
|
|
461
|
+
return Promise.resolve() //
|
|
462
|
+
.then(http.fetch(http.POST, '/user/oneclick/repositories/insert', {
|
|
463
|
+
repositoryUrl,
|
|
464
|
+
}));
|
|
465
|
+
}
|
|
466
|
+
deleteCustomOneClickRepo(repositoryUrl) {
|
|
467
|
+
const http = this.http;
|
|
468
|
+
return Promise.resolve() //
|
|
469
|
+
.then(http.fetch(http.POST, '/user/oneclick/repositories/delete', {
|
|
470
|
+
repositoryUrl,
|
|
471
|
+
}));
|
|
472
|
+
}
|
|
473
|
+
addDockerNode(nodeType, privateKey, remoteNodeIpAddress, sshPort, sshUser, captainIpAddress) {
|
|
474
|
+
const http = this.http;
|
|
475
|
+
return Promise.resolve() //
|
|
476
|
+
.then(http.fetch(http.POST, '/user/system/nodes', {
|
|
477
|
+
nodeType,
|
|
478
|
+
privateKey,
|
|
479
|
+
remoteNodeIpAddress,
|
|
480
|
+
sshPort,
|
|
481
|
+
sshUser,
|
|
482
|
+
captainIpAddress,
|
|
483
|
+
}));
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
exports.default = ApiManager;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare class ErrorFactory {
|
|
2
|
+
readonly OKAY = 100;
|
|
3
|
+
readonly OKAY_BUILD_STARTED = 101;
|
|
4
|
+
readonly OK_PARTIALLY = 102;
|
|
5
|
+
readonly STATUS_ERROR_GENERIC = 1000;
|
|
6
|
+
readonly STATUS_ERROR_CAPTAIN_NOT_INITIALIZED = 1001;
|
|
7
|
+
readonly STATUS_ERROR_USER_NOT_INITIALIZED = 1101;
|
|
8
|
+
readonly STATUS_ERROR_NOT_AUTHORIZED = 1102;
|
|
9
|
+
readonly STATUS_ERROR_ALREADY_EXIST = 1103;
|
|
10
|
+
readonly STATUS_ERROR_BAD_NAME = 1104;
|
|
11
|
+
readonly STATUS_WRONG_PASSWORD = 1105;
|
|
12
|
+
readonly STATUS_AUTH_TOKEN_INVALID = 1106;
|
|
13
|
+
readonly VERIFICATION_FAILED = 1107;
|
|
14
|
+
readonly ILLEGAL_OPERATION = 1108;
|
|
15
|
+
readonly BUILD_ERROR = 1109;
|
|
16
|
+
readonly ILLEGAL_PARAMETER = 1110;
|
|
17
|
+
readonly NOT_FOUND = 1111;
|
|
18
|
+
readonly AUTHENTICATION_FAILED = 1112;
|
|
19
|
+
readonly STATUS_PASSWORD_BACK_OFF = 1113;
|
|
20
|
+
readonly STATUS_ERROR_OTP_REQUIRED = 1114;
|
|
21
|
+
static readonly STATUS_ERROR_PRO_API_KEY_INVALIDATED = 1115;
|
|
22
|
+
readonly UNKNOWN_ERROR = 1999;
|
|
23
|
+
createError(status: number, message: string): any;
|
|
24
|
+
}
|
|
25
|
+
declare const errorFactory: ErrorFactory;
|
|
26
|
+
export default errorFactory;
|