|
| 1 | +import { HttpClient } from '@angular/common/http'; |
| 2 | +import { Injectable } from '@angular/core'; |
| 3 | + |
| 4 | +import { |
| 5 | + CreateInterpreterRepositoryForm, |
| 6 | + Interpreter, |
| 7 | + InterpreterMap, |
| 8 | + InterpreterPropertyTypes, |
| 9 | + InterpreterRepository |
| 10 | +} from '@zeppelin/interfaces'; |
| 11 | +import { InterpreterItem } from '@zeppelin/sdk'; |
| 12 | + |
| 13 | +import { BaseRest } from './base-rest'; |
| 14 | +import { BaseUrlService } from './base-url.service'; |
| 15 | + |
| 16 | +@Injectable({ |
| 17 | + providedIn: 'root' |
| 18 | +}) |
| 19 | +export class InterpreterService extends BaseRest { |
| 20 | + constructor(baseUrlService: BaseUrlService, private http: HttpClient) { |
| 21 | + super(baseUrlService); |
| 22 | + } |
| 23 | + |
| 24 | + getRepositories() { |
| 25 | + return this.http.get<InterpreterRepository[]>(this.restUrl`/interpreter/repository`); |
| 26 | + } |
| 27 | + |
| 28 | + addRepository(repo: CreateInterpreterRepositoryForm) { |
| 29 | + return this.http.post(this.restUrl`/interpreter/repository`, repo); |
| 30 | + } |
| 31 | + |
| 32 | + removeRepository(repoId: string) { |
| 33 | + return this.http.delete(this.restUrl`/interpreter/repository/${repoId}`); |
| 34 | + } |
| 35 | + |
| 36 | + getInterpretersSetting() { |
| 37 | + return this.http.get<Interpreter[]>(this.restUrl`/interpreter/setting`); |
| 38 | + } |
| 39 | + |
| 40 | + getAvailableInterpreters() { |
| 41 | + return this.http.get<InterpreterMap>(this.restUrl`/interpreter`); |
| 42 | + } |
| 43 | + |
| 44 | + getAvailableInterpreterPropertyTypes() { |
| 45 | + return this.http.get<InterpreterPropertyTypes[]>(this.restUrl`/interpreter/property/types`); |
| 46 | + } |
| 47 | + |
| 48 | + addInterpreterSetting(interpreter: Interpreter) { |
| 49 | + return this.http.post<Interpreter>(this.restUrl`/interpreter/setting`, interpreter); |
| 50 | + } |
| 51 | + |
| 52 | + updateInterpreter(interpreter: Interpreter) { |
| 53 | + const { option, properties, dependencies } = interpreter; |
| 54 | + return this.http.put<Interpreter>(this.restUrl`/interpreter/setting/${interpreter.name}`, { |
| 55 | + option, |
| 56 | + properties, |
| 57 | + dependencies |
| 58 | + }); |
| 59 | + } |
| 60 | + |
| 61 | + restartInterpreter(interpreterId: string, noteId: string) { |
| 62 | + return this.http.put<InterpreterItem>(this.restUrl`/interpreter/setting/restart/${interpreterId}`, { noteId }); |
| 63 | + } |
| 64 | + |
| 65 | + removeInterpreterSetting(settingId: string) { |
| 66 | + return this.http.delete(this.restUrl`/interpreter/setting/${settingId}`); |
| 67 | + } |
| 68 | + |
| 69 | + restartInterpreterSetting(settingId: string) { |
| 70 | + return this.http.put(this.restUrl`/interpreter/setting/restart/${settingId}`, null); |
| 71 | + } |
| 72 | +} |
0 commit comments