import { Injectable } from '@angular/core';

import { RPCService } from '@loafer/ng-rpc';
import { Observable } from 'rxjs';

import { Target } from '@overflow/commons-typescript/model/target';
import { Page, PageParams } from '@overflow/commons-typescript/core/model';

@Injectable()
export class TargetService {

  public constructor(
    private rpcService: RPCService,
  ) {

  }

  public regist(target: Target, probeID: number): Observable<Target> {
    return this.rpcService.call<Target>('TargetService.regist', target, probeID);
  }

  public registAll(infraIDs: number[], probeID: number): Observable<Target[]> {
    return this.rpcService.call<Target[]>('TargetService.registAll', infraIDs, probeID);
  }

  public remove(id: number, probeID: number) {
    return this.rpcService.call('TargetService.remove', id, probeID);
  }

  public read(id: number): Observable<Target> {
    return this.rpcService.call<Target>('TargetService.read', id);
  }

  public readAllByProbeID(probeID: number): Observable<Target[]> {
    return this.rpcService.call<Target[]>('TargetService.readAllByProbeID', probeID);
  }

  public readAllTargetByProbeID(probeID: number): Observable<Target[]> {
    return this.rpcService.call<Target[]>('TargetService.readAllTargetByProbeID', probeID);
  }

}
