*/
-import {get, param, post, Request, requestBody, Response, RestBindings} from '@loopback/rest';
-import {Blueprint} from '../models';
-import {inject} from '@loopback/core';
-import {BlueprintService} from '../services';
+import { get, param, post, Request, requestBody, Response, RestBindings, del } from '@loopback/rest';
+import { Blueprint } from '../models';
+import { inject } from '@loopback/core';
+import { BlueprintService } from '../services';
import * as fs from 'fs';
import * as multiparty from 'multiparty';
import * as request_lib from 'request';
-import {appConfig, processorApiConfig} from '../config/app-config';
-import {bluePrintManagementServiceGrpcClient} from '../clients/blueprint-management-service-grpc-client';
-import {BlueprintDetail} from '../models/blueprint.detail.model';
+import { appConfig, processorApiConfig } from '../config/app-config';
+import { bluePrintManagementServiceGrpcClient } from '../clients/blueprint-management-service-grpc-client';
+import { BlueprintDetail } from '../models/blueprint.detail.model';
export class BlueprintRestController {
constructor(
responses: {
'200': {
description: 'Blueprint model instance',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
responses: {
'200': {
description: 'Blueprint model instance',
- content: {'application/json': {schema: {'x-ts-type': BlueprintDetail}}},
+ content: { 'application/json': { schema: { 'x-ts-type': BlueprintDetail } } },
},
},
})
return await this.bpservice.getOneBluePrint(id);
}
+ @del('/controllerblueprint/{id}', {
+ responses: {
+ '200': {
+ description: 'Blueprint model instance',
+ content: { 'application/json': { schema: { 'x-ts-type': BlueprintDetail } } },
+ },
+ },
+ })
+ async deleteBluePrint(@param.path.string('id') id: string) {
+ return await this.bpservice.deleteBluePrint(id);
+ }
+
@get('/controllerblueprint/paged', {
responses: {
'200': {
description: 'Blueprint model instance with pagination',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
responses: {
'200': {
description: 'Blueprint model instance with pagination',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
responses: {
'200': {
description: 'Blueprint model instance',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
responses: {
'200': {
description: 'Blueprint model instance',
- content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
},
},
})
@get('/controllerblueprint/searchByTags/{tags}', {
responses: {
'200': {
- content: {'application/json': {}},
+ content: { 'application/json': {} },
},
},
})
'multipart/form-data': {
// Skip body parsing
'x-parser': 'stream',
- schema: {type: 'object'},
+ schema: { type: 'object' },
},
},
})
- request: Request,
+ request: Request,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise<Response> {
return new Promise((resolve, reject) => {
'multipart/form-data': {
// Skip body parsing
'x-parser': 'stream',
- schema: {type: 'object'},
+ schema: { type: 'object' },
},
},
})
- request: Request,
+ request: Request,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise<Response> {
return new Promise((resolve, reject) => {
'multipart/form-data': {
// Skip body parsing
'x-parser': 'stream',
- schema: {type: 'object'},
+ schema: { type: 'object' },
},
},
})
- request: Request,
+ request: Request,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise<Response> {
return new Promise((resolve, reject) => {
async getFileFromMultiPartForm(request: Request): Promise<multiparty.File> {
return new Promise((resolve, reject) => {
let form = new multiparty.Form();
- form.parse(request, (err: any, fields: any, files: {[x: string]: any[];}) => {
+ form.parse(request, (err: any, fields: any, files: { [x: string]: any[]; }) => {
if (err) reject(err);
let file = files['file'][0]; // get the file from the returned files object
if (!file) {
'multipart/form-data': {
// Skip body parsing
'x-parser': 'stream',
- schema: {type: 'object'},
+ schema: { type: 'object' },
},
},
})
- request: Request,
+ request: Request,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise<Response> {
return new Promise((resolve, reject) => {
if (appConfig.action.grpcEnabled)
return this.uploadFileToBlueprintProcessorGrpc(file, 'PUBLISH', response);
else
- return this.uploadFileToBlueprintProcessor(file, '/execution-service/upload/', response);
+ return this.uploadFileToBlueprintProcessor(file, '/blueprint-model/publish', response);
}, err => {
reject(err);
});