*/
-
-import {
- Count,
- CountSchema,
- Filter,
- repository,
- Where,
-} from '@loopback/repository';
-import {
- post,
- param,
- get,
- getFilterSchemaFor,
- getWhereSchemaFor,
- patch,
- put,
- del,
- requestBody,
- Request,
- Response,
- RestBindings,
-} from '@loopback/rest';
+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 { processorApiConfig, appConfig } from '../config/app-config';
+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(
@inject('services.BlueprintService')
public bpservice: BlueprintService,
- ) { }
+ ) {
+ }
@get('/controllerblueprint/all', {
responses: {
return await this.bpservice.getAllblueprints();
}
+ @get('/controllerblueprint/{id}', {
+ responses: {
+ '200': {
+ description: 'Blueprint model instance',
+ content: { 'application/json': { schema: { 'x-ts-type': BlueprintDetail } } },
+ },
+ },
+ })
+ async getOneBluePrint(@param.path.string('id') id: string) {
+ 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': {
},
})
async getPagedBlueprints(
- @param.query.number('limit') limit: number,
- @param.query.number('offset') offset: number,
- @param.query.string('sort') sort: string) {
- return await this.bpservice.getPagedBueprints(limit, offset, sort);
+ @param.query.number('limit') limit: number,
+ @param.query.number('offset') offset: number,
+ @param.query.string('sort') sort: string,
+ @param.query.string('sortType') sortType: string) {
+ return await this.bpservice.getPagedBueprints(limit, offset, sort, sortType);
}
- @get('/controllerblueprint/metadata/paged/{keyword}', {
- responses: {
- '200': {
- description: 'Blueprint model instance with pagination',
- content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
- },
- },
- })
- async getMetaDataPagedBlueprints(
- @param.path.string('keyword') keyword: string,
- @param.query.number('limit') limit: number,
- @param.query.number('offset') offset: number,
- @param.query.string('sort') sort: string) {
- return await this.bpservice.getMetaDataPagedBlueprints(limit, offset, sort,keyword);
- }
-
- @get('/controllerblueprint/meta-data/{keyword}', {
+ @get('/controllerblueprint/metadata/paged/{keyword}', {
+ responses: {
+ '200': {
+ description: 'Blueprint model instance with pagination',
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
+ },
+ },
+ })
+ async getMetaDataPagedBlueprints(
+ @param.path.string('keyword') keyword: string,
+ @param.query.number('limit') limit: number,
+ @param.query.number('offset') offset: number,
+ @param.query.string('sort') sort: string,
+ @param.query.string('sortType') sortType: string) {
+ return await this.bpservice.getMetaDataPagedBlueprints(limit, offset, sort, keyword, sortType);
+ }
+
+ @get('/controllerblueprint/meta-data/{keyword}', {
responses: {
'200': {
description: 'Blueprint model instance',
return await this.bpservice.getBlueprintsByKeyword(keyword);
}
-
+ @get('/controllerblueprint/by-name/{name}/version/{version}', {
+ responses: {
+ '200': {
+ description: 'Blueprint model instance',
+ content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
+ },
+ },
+ })
+ async getPacakgesByNameAndVersion(@param.path.string('name') name: string, @param.path.string('version') version: string) {
+ return await this.bpservice.getBlueprintByNameAndVersion(name, version);
+ }
@get('/controllerblueprint/searchByTags/{tags}', {
responses: {
this.getFileFromMultiPartForm(request).then(file => {
// if (appConfig.action.deployBlueprint.grpcEnabled)
if (appConfig.action.grpcEnabled)
- return this.uploadFileToBlueprintProcessorGrpc(file, "DRAFT", response);
+ return this.uploadFileToBlueprintProcessorGrpc(file, 'DRAFT', response);
else
- return this.uploadFileToBlueprintController(file, "/blueprint-model/", response);
+ return this.uploadFileToBlueprintController(file, '/blueprint-model/', response);
}, err => {
reject(err);
});
this.getFileFromMultiPartForm(request).then(file => {
// if (appConfig.action.deployBlueprint.grpcEnabled)
if (appConfig.action.grpcEnabled)
- return this.uploadFileToBlueprintProcessorGrpc(file, "PUBLISH", response);
+ return this.uploadFileToBlueprintProcessorGrpc(file, 'PUBLISH', response);
else
- return this.uploadFileToBlueprintController(file, "/blueprint-model/publish/", response);
+ return this.uploadFileToBlueprintController(file, '/blueprint-model/publish/', response);
}, err => {
reject(err);
});
return new Promise((resolve, reject) => {
this.getFileFromMultiPartForm(request).then(file => {
if (appConfig.action.grpcEnabled)
- return this.uploadFileToBlueprintProcessorGrpc(file, "ENRICH", response);
+ return this.uploadFileToBlueprintProcessorGrpc(file, 'ENRICH', response);
else
- return this.uploadFileToBlueprintController(file, "/blueprint-model/enrich/", response)
+ return this.uploadFileToBlueprintController(file, '/blueprint-model/enrich/', response);
// this.uploadFileToBlueprintController(file, "/blueprint-model/enrich/", response).then(resp => {
// resolve(resp);
// }, err => {
if (appConfig.action.grpcEnabled)
return this.downloadFileFromBlueprintProcessorGrpc(name, version, response);
else
- return this.downloadFileFromBlueprintController("/blueprint-model/download/by-name/" + name + "/version/" + version, response);
+ return this.downloadFileFromBlueprintController('/blueprint-model/download/by-name/' + name + '/version/' + version, response);
}
resolve(file);
}
});
- })
+ });
}
@post('/controllerblueprint/deploy-blueprint')
this.getFileFromMultiPartForm(request).then(file => {
// if (appConfig.action.deployBlueprint.grpcEnabled)
if (appConfig.action.grpcEnabled)
- return this.uploadFileToBlueprintProcessorGrpc(file, "PUBLISH", response);
+ 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);
});
url: url,
headers: {
Authorization: authToken,
- 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
+ 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW',
},
formData: {
file: {
value: fs.createReadStream(file.path),
options: {
filename: 'cba.zip',
- contentType: 'application/zip'
- }
- }
- }
+ contentType: 'application/zip',
+ },
+ },
+ },
};
var removeTempFile = () => {
console.error(err);
}
});
- }
+ };
return new Promise((resolve, reject) => {
request_lib.post(options)
- .on("error", err => {
+ .on('error', err => {
reject(err);
})
.pipe(response)
- .once("finish", () => {
+ .once('finish', () => {
removeTempFile();
resolve(response);
});
- })
+ });
}
async downloadFileFromBlueprintController(uri: string, response: Response): Promise<Response> {
url: url,
headers: {
Authorization: authToken,
- }
+ },
};
return new Promise((resolve, reject) => {
request_lib.get(options)
- .on("error", err => {
+ .on('error', err => {
reject(err);
})
.pipe(response)
- .once("finish", () => {
+ .once('finish', () => {
resolve(response);
});
- })
+ });
}
async uploadFileToBlueprintProcessorGrpc(file: multiparty.File, actionName: string, response: Response): Promise<Response> {
});
});
}
+
async downloadFileFromBlueprintProcessorGrpc(blueprintName: string, blueprintVersion: string, response: Response): Promise<Response> {
return new Promise<Response>((resolve, reject) => {
bluePrintManagementServiceGrpcClient.downloadBlueprint(blueprintName, blueprintVersion)