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';
|
2022-02-27 17:54:25 +00:00
|
|
|
import { Transformers } from '@definitions/admin';
|
2021-10-03 20:23:06 +00:00
|
|
|
|
2021-11-04 20:32:42 +00:00
|
|
|
export type CreateEggVariable = Omit<EggVariable, 'id' | 'eggId' | 'createdAt' | 'updatedAt' | 'relationships'>;
|
|
|
|
|
|
|
|
export default async (eggId: number, variable: CreateEggVariable): Promise<EggVariable> => {
|
|
|
|
const { data } = await http.post(
|
|
|
|
`/api/application/eggs/${eggId}/variables`,
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2022-02-27 16:26:13 +00:00
|
|
|
return Transformers.toEggVariable(data);
|
2021-10-03 20:23:06 +00:00
|
|
|
};
|