2021-09-13 01:40:10 +00:00
|
|
|
import http from '@/api/http';
|
2021-09-15 21:37:17 +00:00
|
|
|
import { Allocation, rawDataToAllocation } from '@/api/admin/nodes/getAllocations';
|
2021-09-13 01:40:10 +00:00
|
|
|
|
|
|
|
export interface Values {
|
|
|
|
ip: string;
|
|
|
|
ports: number[];
|
|
|
|
alias?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default (id: string | number, values: Values, include: string[] = []): Promise<Allocation[]> => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
http.post(`/api/application/nodes/${id}/allocations`, values, { params: { include: include.join(',') } })
|
|
|
|
.then(({ data }) => resolve((data || []).map(rawDataToAllocation)))
|
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|