support-multiple-ric-instances
[portal/ric-dashboard.git] / webapp-frontend / src / app / services / caas-ingress / caas-ingress.service.ts
index 359a08f..42cb928 100644 (file)
  * ========================LICENSE_END===================================
  */
 
-import { Injectable } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
+import { Injectable } from '@angular/core';
 import { V1PodList } from '@kubernetes/client-node';
 import { Observable } from 'rxjs';
+import { CommonService } from '../common/common.service';
 
 /**
 * Services for calling the Dashboard's caas-ingress endpoints to get Kubernetes details.
@@ -31,18 +32,12 @@ import { Observable } from 'rxjs';
 })
 export class CaasIngressService {
 
-  private basePath = 'api/caas-ingress';
+  private component = 'caas-ingress';
   private podsPath = 'pods';
 
-  private buildPath(...args: any[]) {
-    let result = this.basePath;
-    args.forEach(part => {
-      result = result + '/' + part;
-    });
-    return result;
-  }
-
-  constructor(private httpClient: HttpClient) {
+  constructor(
+    private httpClient: HttpClient,
+    private commonSvc: CommonService) {
     // injects to variable httpClient
   }
 
@@ -50,8 +45,8 @@ export class CaasIngressService {
    * Gets list of pods
    * @returns Observable that should yield a V1PodList
    */
-  getPodList(cluster: string, namespace: string): Observable<V1PodList> {
-    const url = this.buildPath('pods', 'cluster', cluster, 'namespace', namespace);
+  getPodList(instanceKey: string, cluster: string, namespace: string): Observable<V1PodList> {
+    const url = this.commonSvc.buildPath(instanceKey, this.component, 'pods', 'cluster', cluster, 'namespace', namespace);
     return this.httpClient.get<V1PodList>(url);
   }