Merge "add API to list blueprints with pagination in loopback server"
authorBrinda Santh Muthuramalingam <brindasanth@in.ibm.com>
Thu, 14 Nov 2019 16:01:55 +0000 (16:01 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 14 Nov 2019 16:01:55 +0000 (16:01 +0000)
cds-ui/server/src/controllers/blueprint-rest.controller.ts
cds-ui/server/src/datasources/blueprint.datasource-template.ts
cds-ui/server/src/services/blueprint.service.ts

index b529528..49ecb9d 100644 (file)
@@ -69,6 +69,21 @@ export class BlueprintRestController {
     return await this.bpservice.getAllblueprints();
   }
 
+  @get('/controllerblueprint/paged', {
+    responses: {
+      '200': {
+        description: 'Blueprint model instance with pagination',
+        content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
+      },
+    },
+  })
+  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);
+  }
+
  @get('/controllerblueprint/meta-data/{keyword}', {
     responses: {
       '200': {
index b0aaf01..9140218 100644 (file)
@@ -38,21 +38,36 @@ export default {
 
         }
     },
-  {
-            "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": "$.*"
+    {
+        "template": {
+            "method": "GET",
+            "url": processorApiConfig.http.url + "/blueprint-model/meta-data/{keyword}",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
             },
-            "functions": {
-                "getBlueprintsByKeyword": ["keyword"]
+            "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
+            },
+            "responsePath": "$",
         },
+        "functions": {
+            "getPagedBueprints": ["limit","offset", "sort"],
+        }
+    },
 ]
 };
index 7952859..bc93fa1 100644 (file)
@@ -6,6 +6,7 @@ export interface BlueprintService {
    getAllblueprints(): Promise<any>;
    getBlueprintsByKeyword(keyword: string): Promise<any>;
    getByTags(tags: string): Promise<JSON>;
+   getPagedBueprints(limit: number, offset: number , sort: string): Promise<any>;
 }
 
 export class BlueprintServiceProvider implements Provider<BlueprintService> {