Merge "CDS index content"
[ccsdk/cds.git] / cds-ui / server / src / controllers / data-dictionary.controller.ts
1 // Uncomment these imports to begin using these cool features!
2
3 // import {inject} from '@loopback/context';
4 import {
5   post,
6   param,
7   get,
8   getFilterSchemaFor,
9   getWhereSchemaFor,
10   patch,
11   put,
12   del,
13   requestBody,
14   Request,
15   Response,
16   RestBindings,
17 } from '@loopback/rest';
18 import { inject } from '@loopback/core';
19 import { ResourceDictionaryService } from '../services';
20
21 const REST_RESOURCE_DICTIONARY_BASIC_AUTH_HEADER = process.env.REST_BLUEPRINT_CONTROLLER_BASIC_AUTH_HEADER || "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==";
22 export class DataDictionaryController {
23   constructor(
24     @inject('services.ResourceDictionaryService')
25     public rdservice: ResourceDictionaryService,
26   ) { }
27
28   @get('/resourcedictionary/{name}', {
29     responses: {
30       '200': {
31         content: { 'application/json': {} },
32       },
33     },
34   })
35   async getByName(@param.path.string('name') name: string) {
36     return await this.rdservice.getByName(name, REST_RESOURCE_DICTIONARY_BASIC_AUTH_HEADER);
37   }
38   @get('/resourcedictionary/{tags}', {
39     responses: {
40       '200': {
41         content: { 'application/json': {} },
42       },
43     },
44   })
45   async getByTags(@param.path.string('tags') tags: string) {
46     return await this.rdservice.getByTags(tags, REST_RESOURCE_DICTIONARY_BASIC_AUTH_HEADER);
47   }
48
49   @get('/resourcedictionary/source-mapping', {
50     responses: {
51       '200': {
52         content: { 'application/json': {} },
53       },
54     },
55   })
56   async getSourceMapping() {
57     return await this.rdservice.getSourceMapping(REST_RESOURCE_DICTIONARY_BASIC_AUTH_HEADER);
58   }
59   @post('/resourcedictionary/save', {
60     responses: {
61       '200': {
62         content: { 'application/json': {} }
63       }
64     },
65   })
66   async save(@requestBody({
67     content: { 'application/json': { schema: { 'x-ts-type': JSON } } },
68     accepts: { 'application/json': { schema: { 'x-ts-type': JSON } } }
69   }) resourceDictionary: JSON): Promise<any> {
70     return await this.rdservice.save(REST_RESOURCE_DICTIONARY_BASIC_AUTH_HEADER, resourceDictionary);
71   }
72   @post('/resourcedictionary/search/by-names', {
73     responses: {
74       '200': {
75         content: { 'application/json': {} }
76       }
77     },
78   })
79   async searchByNames(@requestBody({
80     content: { 'application/json': { schema: { 'x-ts-type': JSON } } },
81     accepts: { 'application/json': { schema: { 'x-ts-type': JSON } } }
82   }) resourceDictionaryList: JSON): Promise<any> {
83     return await this.rdservice.searchbyNames(REST_RESOURCE_DICTIONARY_BASIC_AUTH_HEADER, resourceDictionaryList);
84   }
85 }