2021-10-03 20:23:06 +00:00
|
|
|
import http from '@/api/http';
|
2021-11-04 20:32:42 +00:00
|
|
|
import { EggVariable } from '@/api/admin/egg';
|
|
|
|
import { AdminTransformers } from '@/api/admin/transformers';
|
2021-10-03 20:23:06 +00:00
|
|
|
|
2021-11-04 20:32:42 +00:00
|
|
|
export default async (eggId: number, variables: Omit<EggVariable, 'eggId' | 'createdAt' | 'updatedAt'>[]): Promise<EggVariable[]> => {
|
|
|
|
const { data } = await http.patch(
|
|
|
|
`/api/application/eggs/${eggId}/variables`,
|
|
|
|
variables.map(variable => ({
|
|
|
|
id: variable.id,
|
|
|
|
name: variable.name,
|
|
|
|
description: variable.description,
|
|
|
|
env_variable: variable.environmentVariable,
|
|
|
|
default_value: variable.defaultValue,
|
|
|
|
user_viewable: variable.isUserViewable,
|
|
|
|
user_editable: variable.isUserEditable,
|
|
|
|
rules: variable.rules,
|
|
|
|
})),
|
|
|
|
);
|
|
|
|
|
|
|
|
return data.data.map(AdminTransformers.toEggVariable);
|
2021-10-03 20:23:06 +00:00
|
|
|
};
|