2023-11-18 10:47:01 +00:00
|
|
|
import { APIService } from "services/api.service";
|
|
|
|
// helpers
|
|
|
|
import { API_BASE_URL } from "helpers/common.helper";
|
|
|
|
// types
|
2023-11-27 11:45:11 +00:00
|
|
|
import type {
|
|
|
|
IFormattedInstanceConfiguration,
|
|
|
|
IInstance,
|
|
|
|
IInstanceAdmin,
|
|
|
|
IInstanceConfiguration,
|
|
|
|
} from "types/instance";
|
2023-11-18 10:47:01 +00:00
|
|
|
|
|
|
|
export class InstanceService extends APIService {
|
|
|
|
constructor() {
|
|
|
|
super(API_BASE_URL);
|
|
|
|
}
|
|
|
|
|
|
|
|
async getInstanceInfo(): Promise<IInstance> {
|
|
|
|
return this.get("/api/licenses/instances/")
|
|
|
|
.then((response) => response.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-11-27 11:45:11 +00:00
|
|
|
async getInstanceAdmins(): Promise<IInstanceAdmin[]> {
|
|
|
|
return this.get("/api/licenses/instances/admins/")
|
|
|
|
.then((response) => response.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async updateInstanceInfo(data: Partial<IInstance>): Promise<IInstance> {
|
2023-11-18 10:47:01 +00:00
|
|
|
return this.patch("/api/licenses/instances/", data)
|
2023-11-27 11:45:11 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
2023-11-18 10:47:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async getInstanceConfigurations() {
|
|
|
|
return this.get("/api/licenses/instances/configurations/")
|
|
|
|
.then((response) => response.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error;
|
|
|
|
});
|
|
|
|
}
|
2023-11-20 15:16:49 +00:00
|
|
|
|
|
|
|
async updateInstanceConfigurations(
|
|
|
|
data: Partial<IFormattedInstanceConfiguration>
|
|
|
|
): Promise<IInstanceConfiguration[]> {
|
|
|
|
return this.patch("/api/licenses/instances/configurations/", data)
|
2023-11-27 11:45:11 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
2023-11-20 15:16:49 +00:00
|
|
|
}
|
2023-11-18 10:47:01 +00:00
|
|
|
}
|