misc_pterodactyl-panel/resources/scripts/api/admin/eggs/createEggVariable.ts
2021-11-04 14:33:24 -06:00

22 lines
845 B
TypeScript

import http from '@/api/http';
import { EggVariable } from '@/api/admin/egg';
import { AdminTransformers } from '@/api/admin/transformers';
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,
},
);
return AdminTransformers.toEggVariable(data);
};