Modified logic to handle Modify/Create/Delete Policy Instance
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / services / ei / ei.service.ts
index 976b7b8..3be9b8b 100644 (file)
 
 import { Injectable } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
-import { Observable } from 'rxjs';
-import { map } from 'rxjs/operators';
-import { EIJob, EIType, EIProducer } from '../../interfaces/ei.jobs';
-import { ControlpanelSuccessTransport } from '../../interfaces/controlpanel.types';
+import { Observable, of } from 'rxjs';
+import { EIJob, EIProducer } from '../../interfaces/ei.types';
 
 /**
  * Services for calling the EI endpoints.
@@ -33,10 +31,9 @@ import { ControlpanelSuccessTransport } from '../../interfaces/controlpanel.type
 })
 export class EIService {
 
-    private basePath = 'api/enrichment';
-    private eiTypePath = 'eitypes';
-    private eiJobPath = 'eijobs';
-    private eiProducerPath = 'eiproducers';
+    private basePath = '/ei-producer/v1';
+    eiJobsPath = 'eijobs';
+    eiProducersPath = 'eiproducers';
 
     private buildPath(...args: any[]) {
         let result = this.basePath;
@@ -50,30 +47,18 @@ export class EIService {
         // injects to variable httpClient
     }
 
-    /**
-     * Gets version details
-     * @returns Observable that should yield a String
-     */
-    getVersion(): Observable<string> {
-        const url = this.buildPath('version');
-        return this.httpClient.get<ControlpanelSuccessTransport>(url).pipe(
-            // Extract the string here
-            map(res => res['data'])
-        );
+    getProducerIds(): Observable<String[]> {
+        const url = this.buildPath(this.eiProducersPath);
+        return this.httpClient.get<String[]>(url);
     }
 
-    getEITypes(): Observable<EIType[]> {
-        const url = this.buildPath(this.eiTypePath);
-        return this.httpClient.get<EIType[]>(url);
-    }
-
-    getEIJobs(): Observable<EIJob[]> {
-        const url = this.buildPath(this.eiJobPath);
+    getJobsForProducer(producerId: String): Observable<EIJob[]> {
+        const url = this.buildPath(this.eiProducersPath, producerId, this.eiJobsPath);
         return this.httpClient.get<EIJob[]>(url);
     }
 
     getEIProducers(): Observable<EIProducer[]> {
-        const url = this.buildPath(this.eiProducerPath);
+        const url = this.buildPath(this.eiProducersPath);
         return this.httpClient.get<EIProducer[]>(url);
     }
 }