fix(scaffolder): schema adjusted

This commit is contained in:
Ivan Shmidt
2020-07-01 18:51:33 +02:00
parent e4dd9bd5b2
commit 34399824a6
6 changed files with 42 additions and 4 deletions
+13 -3
View File
@@ -37,20 +37,30 @@ export class ScaffolderApi {
this.basePath = basePath;
}
/**
*
* @param template Template entity for the scaffolder to use. New project is going to be created out of this template.
* @param values Parameters for the template, e.g. name, description
*/
async scaffold(
template: TemplateEntityV1alpha1,
values: Record<string, any>,
) {
const url = `${this.apiOrigin}${this.basePath}/jobs`;
const { id: jobId } = await fetch(url, {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ template, values }),
}).then(x => x.json());
});
return jobId;
if (response.status !== 201) {
throw new Error(await response.text());
}
const { id } = await response.json();
return id;
}
async getJob(jobId: string) {