badguardhome/client2/src/lib/apis/tls.ts
Eugene Burkov 5e20ac7ed5 Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master

Squashed commit of the following:

commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Dec 29 19:23:09 2020 +0300

    Merge branch 'master' into beta-client-2

commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Dec 29 17:25:14 2020 +0300

    all: upgrade github actions node version

commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com>
Date:   Tue Dec 29 16:57:14 2020 +0300

    all: beta client squashed
2020-12-29 19:53:56 +03:00

62 lines
2.1 KiB
TypeScript

import TlsConfig, { ITlsConfig } from 'Entities/TlsConfig';
// This file was autogenerated. Please do not change.
// All changes will be overwrited on commit.
export default class TlsApi {
static async tlsConfigure(tlsconfig: ITlsConfig): Promise<ITlsConfig | string[] | Error> {
const haveError: string[] = [];
const tlsconfigValid = new TlsConfig(tlsconfig);
haveError.push(...tlsconfigValid.validate());
if (haveError.length > 0) {
return Promise.resolve(haveError);
}
return await fetch(`/control/tls/configure`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(tlsconfigValid.serialize()),
}).then(async (res) => {
if (res.status === 200) {
return res.json();
} else {
return new Error(String(res.status));
}
})
}
static async tlsStatus(): Promise<ITlsConfig | Error> {
return await fetch(`/control/tls/status`, {
method: 'GET',
}).then(async (res) => {
if (res.status === 200) {
return res.json();
} else {
return new Error(String(res.status));
}
})
}
static async tlsValidate(tlsconfig: ITlsConfig): Promise<ITlsConfig | string[] | Error> {
const haveError: string[] = [];
const tlsconfigValid = new TlsConfig(tlsconfig);
haveError.push(...tlsconfigValid.validate());
if (haveError.length > 0) {
return Promise.resolve(haveError);
}
return await fetch(`/control/tls/validate`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(tlsconfigValid.serialize()),
}).then(async (res) => {
if (res.status === 200) {
return res.json();
} else {
return new Error(String(res.status));
}
})
}
}