2021-07-14 22:43:59 +00:00
|
|
|
import http, { FractalResponseData } from '@/api/http';
|
2021-05-20 22:00:46 +00:00
|
|
|
|
|
|
|
export interface Allocation {
|
|
|
|
id: number;
|
|
|
|
ip: string;
|
|
|
|
alias: string | null;
|
|
|
|
port: number;
|
|
|
|
notes: string | null;
|
2021-07-14 22:43:59 +00:00
|
|
|
assigned: boolean;
|
2021-05-20 22:00:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-14 22:43:59 +00:00
|
|
|
export const rawDataToAllocation = (data: FractalResponseData): Allocation => ({
|
|
|
|
id: data.attributes.id,
|
|
|
|
ip: data.attributes.ip,
|
|
|
|
alias: data.attributes.ip_alias,
|
|
|
|
port: data.attributes.port,
|
|
|
|
notes: data.attributes.notes,
|
|
|
|
assigned: data.attributes.assigned,
|
|
|
|
});
|
|
|
|
|
|
|
|
export default (uuid: string): Promise<Allocation[]> => {
|
2021-05-20 22:00:46 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2021-07-14 22:43:59 +00:00
|
|
|
http.get(`/api/application/nodes/${uuid}/allocations`)
|
|
|
|
.then(({ data }) => resolve((data.data || []).map(rawDataToAllocation)))
|
2021-05-20 22:00:46 +00:00
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|