2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved.
5 ===================================================================
7 Unless otherwise specified, all software contained herein is licensed
8 under the Apache License, Version 2.0 (the License);
9 you may not use this software except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19 ============LICENSE_END============================================
30 } from '@loopback/repository';
41 } from '@loopback/rest';
42 import {Blueprint} from '../models';
43 import {BlueprintRepository} from '../repositories';
45 export class BlueprintRestController {
47 @repository(BlueprintRepository)
48 public blueprintRepository : BlueprintRepository,
51 @post('/blueprints', {
54 description: 'Blueprint model instance',
55 content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
59 async create(@requestBody() blueprint: Blueprint): Promise<Blueprint> {
60 return await this.blueprintRepository.create(blueprint);
63 @get('/blueprints/count', {
66 description: 'Blueprint model count',
67 content: {'application/json': {schema: CountSchema}},
72 @param.query.object('where', getWhereSchemaFor(Blueprint)) where?: Where,
74 return await this.blueprintRepository.count(where);
80 description: 'Array of Blueprint model instances',
83 schema: {type: 'array', items: {'x-ts-type': Blueprint}},
90 @param.query.object('filter', getFilterSchemaFor(Blueprint)) filter?: Filter,
91 ): Promise<Blueprint[]> {
92 return await this.blueprintRepository.find(filter);
95 @patch('/blueprints', {
98 description: 'Blueprint PATCH success count',
99 content: {'application/json': {schema: CountSchema}},
104 @requestBody() blueprint: Blueprint,
105 @param.query.object('where', getWhereSchemaFor(Blueprint)) where?: Where,
107 return await this.blueprintRepository.updateAll(blueprint, where);
110 @get('/blueprints/{id}', {
113 description: 'Blueprint model instance',
114 content: {'application/json': {schema: {'x-ts-type': Blueprint}}},
118 async findById(@param.path.number('id') id: number): Promise<Blueprint> {
119 return await this.blueprintRepository.findById(id);
122 @patch('/blueprints/{id}', {
125 description: 'Blueprint PATCH success',
130 @param.path.number('id') id: number,
131 @requestBody() blueprint: Blueprint,
133 await this.blueprintRepository.updateById(id, blueprint);
136 @put('/blueprints/{id}', {
139 description: 'Blueprint PUT success',
144 @param.path.number('id') id: number,
145 @requestBody() blueprint: Blueprint,
147 await this.blueprintRepository.replaceById(id, blueprint);
150 @del('/blueprints/{id}', {
153 description: 'Blueprint DELETE success',
157 async deleteById(@param.path.number('id') id: number): Promise<void> {
158 await this.blueprintRepository.deleteById(id);