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

import 'rxjs/add/operator/map';

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

import { Infra } from '../model';
import { Page, PageParams } from 'app/commons/model';
import { Domain } from 'packages/domain/model';
import { Probe } from 'packages/probe/model';

@Injectable()
export class InfraService {

  public constructor(
    private rpcService: RPCService,
  ) {

  }

  public readAllByDomain(domain: Domain, pageParams: PageParams): Observable<Page> {
    return this.rpcService.call('InfraService.readAllByDomain', domain, pageParams);
  }

  public readAllByProbe(probe: Probe, pageParams: PageParams): Observable<Page> {
    return this.rpcService.call('InfraService.readAllByProbe', probe, pageParams);
  }

  public read(id: string): Observable<Infra> {
    return this.rpcService.call('InfraService.read', id);
  }
}
