Creating findOneBluePrintModel (configuration) 35/98835/3
authorShaaban Ebrahim <shaaban.altanany@gmail.com>
Tue, 26 Nov 2019 06:38:53 +0000 (08:38 +0200)
committerShaabanEltanany <shaaban.eltanany.ext@orange.com>
Wed, 4 Dec 2019 08:19:14 +0000 (10:19 +0200)
Issue-ID: CCSDK-1770
Signed-off-by: Shaaban Ebrahim <shaaban.eltanany.ext@orange.com>
Change-Id: I61a947533a1b61138d004a22c5a796d09ab2c8d9

cds-ui/server/src/controllers/blueprint-rest.controller.ts
cds-ui/server/src/datasources/blueprint.datasource-template.ts
cds-ui/server/src/models/blueprint.detail.model.ts [new file with mode: 0644]
cds-ui/server/src/services/blueprint.service.ts

index 1a8de6b..b2a1128 100644 (file)
@@ -50,6 +50,7 @@ import * as multiparty from 'multiparty';
 import * as request_lib from 'request';
 import { processorApiConfig, appConfig } from '../config/app-config';
 import { bluePrintManagementServiceGrpcClient } from '../clients/blueprint-management-service-grpc-client';
+import {BlueprintDetail} from '../models/blueprint.detail.model';
 
 export class BlueprintRestController {
   constructor(
@@ -68,6 +69,18 @@ export class BlueprintRestController {
   async getall() {
     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);
+    }
+
 
   @get('/controllerblueprint/paged', {
     responses: {
index a7cea1d..d51d1ba 100644 (file)
@@ -21,11 +21,10 @@ export default {
             "getAllblueprints": []
 
         }
-    },
-    {
+    }, {
         "template": {
             "method": "GET",
-            "url": processorApiConfig.http.url + "/blueprint-model/search/{tags}",
+            "url": processorApiConfig.http.url + "/blueprint-model/{id}",
             "headers": {
                 "accepts": "application/json",
                 "content-type": "application/json",
@@ -34,41 +33,58 @@ export default {
             "responsePath": "$.*"
         },
         "functions": {
-            "getByTags": ["tags"]
+            "getOneBluePrint": ["id"]
 
         }
     },
-    {
-        "template": {
-            "method": "GET",
-            "url": processorApiConfig.http.url + "/blueprint-model/meta-data/{keyword}",
-            "headers": {
-                "accepts": "application/json",
-                "content-type": "application/json",
-                "authorization": processorApiConfig.http.authToken
+
+        {
+            "template": {
+                "method": "GET",
+                "url": processorApiConfig.http.url + "/blueprint-model/search/{tags}",
+                "headers": {
+                    "accepts": "application/json",
+                    "content-type": "application/json",
+                    "authorization": processorApiConfig.http.authToken
+                },
+                "responsePath": "$.*"
             },
-            "responsePath": "$.*"
+            "functions": {
+                "getByTags": ["tags"]
+
+            }
         },
-        "functions": {
-            "getBlueprintsByKeyword": ["keyword"]
+        {
+            "template": {
+                "method": "GET",
+                "url": processorApiConfig.http.url + "/blueprint-model/meta-data/{keyword}",
+                "headers": {
+                    "accepts": "application/json",
+                    "content-type": "application/json",
+                    "authorization": processorApiConfig.http.authToken
+                },
+                "responsePath": "$.*"
+            },
+            "functions": {
+                "getBlueprintsByKeyword": ["keyword"]
 
-        }
-    },
-    {
-        "template": {
-            "method": "GET",
-            "url": processorApiConfig.http.url + "/blueprint-model/paged?limit={limit}&offset={offset}&sort={sort}",
-            "headers": {
-                "accepts": "application/json",
-                "content-type": "application/json",
-                "authorization": processorApiConfig.http.authToken
+            }
+        },
+        {
+            "template": {
+                "method": "GET",
+                "url": processorApiConfig.http.url + "/blueprint-model/paged?limit={limit}&offset={offset}&sort={sort}",
+                "headers": {
+                    "accepts": "application/json",
+                    "content-type": "application/json",
+                    "authorization": processorApiConfig.http.authToken
+                },
+                "responsePath": "$",
             },
-            "responsePath": "$",
+            "functions": {
+                "getPagedBueprints": ["limit", "offset", "sort"],
+            }
         },
-        "functions": {
-            "getPagedBueprints": ["limit","offset", "sort"],
-        }
-    },
         {
             "template": {
                 "method": "GET",
@@ -81,8 +97,9 @@ export default {
                 "responsePath": "$",
             },
             "functions": {
-                "getMetaDataPagedBlueprints": ["limit","offset", "sort","keyword"],
+                "getMetaDataPagedBlueprints": ["limit", "offset", "sort", "keyword"],
             }
         },
-]
+    ]
+
 };
diff --git a/cds-ui/server/src/models/blueprint.detail.model.ts b/cds-ui/server/src/models/blueprint.detail.model.ts
new file mode 100644 (file)
index 0000000..1a6b9f2
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+============LICENSE_END============================================
+*/
+
+
+import { model, property} from '@loopback/repository';
+import {Blueprint} from "./blueprint.model";
+
+@model()
+export class BlueprintDetail extends Blueprint {
+
+  @property({
+    type: 'object',
+  })
+  blueprintModelContent?: object;
+
+  constructor(data?: Partial<BlueprintDetail>) {
+    super(data);
+  }
+}
index b6474a3..875eb5e 100644 (file)
@@ -3,6 +3,7 @@ import {inject, Provider} from '@loopback/core';
 import {BlueprintDataSource} from '../datasources';
 
 export interface BlueprintService {
+    getOneBluePrint(id: string): any;
    getAllblueprints(): Promise<any>;
    getBlueprintsByKeyword(keyword: string): Promise<any>;
    getByTags(tags: string): Promise<JSON>;