From 13f226fa998fd391d540be7a79372ee7fd9457a6 Mon Sep 17 00:00:00 2001 From: stevereis <stevereis93@gmail.com> Date: Mon, 13 Sep 2021 16:12:57 +0200 Subject: [PATCH] Added API call for algorithms (Exareme) --- api/src/engine/connectors/datashield/main.connector.ts | 5 +++++ api/src/engine/connectors/exareme/main.connector.ts | 9 +++++++++ api/src/engine/engine.controller.ts | 6 ++++++ api/src/engine/engine.interfaces.ts | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/api/src/engine/connectors/datashield/main.connector.ts b/api/src/engine/connectors/datashield/main.connector.ts index ee877e2..643cd6d 100644 --- a/api/src/engine/connectors/datashield/main.connector.ts +++ b/api/src/engine/connectors/datashield/main.connector.ts @@ -1,9 +1,14 @@ import { HttpService } from "@nestjs/axios"; +import { Observable } from "rxjs"; import { IEngineOptions, IEngineService } from "src/engine/engine.interfaces"; export default class DataShieldService implements IEngineService { constructor(private readonly options: IEngineOptions, private readonly httpService: HttpService) { } + getAlgorithms(): Observable<string> { + throw new Error("Method not implemented."); + } + demo(): string { return "datashield"; } diff --git a/api/src/engine/connectors/exareme/main.connector.ts b/api/src/engine/connectors/exareme/main.connector.ts index b8a6ae8..10aa652 100644 --- a/api/src/engine/connectors/exareme/main.connector.ts +++ b/api/src/engine/connectors/exareme/main.connector.ts @@ -1,9 +1,18 @@ import { HttpService } from "@nestjs/axios"; +import { map, Observable } from "rxjs"; import { IEngineOptions, IEngineService } from "src/engine/engine.interfaces"; export default class ExaremeService implements IEngineService { constructor(private readonly options: IEngineOptions, private readonly httpService: HttpService) { } + getAlgorithms(): Observable<string> { + const path = this.options.baseurl + "algorithms"; + + return this.httpService.get<string>(path).pipe( + map(response => response.data) + ); + } + demo(): string { return "exareme" } diff --git a/api/src/engine/engine.controller.ts b/api/src/engine/engine.controller.ts index 5c9e3c5..a5bae28 100644 --- a/api/src/engine/engine.controller.ts +++ b/api/src/engine/engine.controller.ts @@ -1,5 +1,6 @@ import { HttpService } from '@nestjs/axios'; import { Controller, Get, Inject } from '@nestjs/common'; +import { Observable } from 'rxjs'; import { ENGINE_SERVICE } from './engine.constants'; import { IEngineService } from './engine.interfaces'; @@ -11,4 +12,9 @@ export class EngineController { getTest(): string { return this.engineService.demo(); } + + @Get('/algorithms') + getAlgorithms(): Observable<string> { + return this.engineService.getAlgorithms(); + } } diff --git a/api/src/engine/engine.interfaces.ts b/api/src/engine/engine.interfaces.ts index 271cbb1..f9cbacc 100644 --- a/api/src/engine/engine.interfaces.ts +++ b/api/src/engine/engine.interfaces.ts @@ -1,7 +1,12 @@ +import { Observable } from "rxjs"; + export interface IEngineOptions { type: string; + baseurl: string; } export interface IEngineService { demo(): string; + + getAlgorithms(): Observable<string>; } \ No newline at end of file -- GitLab