import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { RPCService } from '@loafer/ng-rpc'; import { Infra } from '@overflow/commons-typescript/model/infra'; import { Page, PageParams } from '@overflow/commons-typescript/core/model'; import { Host, Service } from '@overflow/commons-typescript'; import { gzip } from 'pako'; @Injectable() export class InfraService { public constructor( private rpcService: RPCService, ) { } public regist(infra: Infra): Observable { return this.rpcService.call('InfraService.regist', infra); } public registDiscoverd(probeID: number, hosts: Host[], services: Service[]): Observable { const discoverd = { hosts: hosts, services: services, }; const json = JSON.stringify(discoverd); const compressed = gzip(json, { to: 'string' }); const base64 = btoa(compressed); return this.rpcService.call('InfraService.registDiscoverd', probeID, base64); } public read(id: string): Observable { return this.rpcService.call('InfraService.read', id); } public readAllByProbeID(probeID: number, pageParams: PageParams): Observable> { return this.rpcService.call>('InfraService.readAllByProbeID', probeID, pageParams); } public readAllByDomainID(domainID: number, pageParams: PageParams): Observable> { return this.rpcService.call>('InfraService.readAllByDomainID', domainID, pageParams); } public readAllInfraZoneByProbeDomainID(probeDomainID: number): Observable { return this.rpcService.call('InfraService.readAllInfraZoneByProbeDomainID', probeDomainID); } public readAllByMetaInfraTypeKeyAndProbeID(metaInfraTypeKey: string, probeID: number): Observable { return this.rpcService.call('InfraService.readAllByMetaInfraTypeKeyAndProbeID', metaInfraTypeKey, probeID); } }