56 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { Injectable } from '@angular/core';
 | 
						|
import { Observable } from 'rxjs';
 | 
						|
import { RPCService } from '@loafer/ng-rpc';
 | 
						|
import { Infra } from '@overflow/commons-typescript/model/infra';
 | 
						|
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<Infra> {
 | 
						|
    return this.rpcService.call<Infra>('InfraService.regist', infra);
 | 
						|
  }
 | 
						|
 | 
						|
  public registDiscoverd(probeID: number, hosts: Host[], services: Service[]): Observable<Infra[]> {
 | 
						|
    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<Infra[]>('InfraService.registDiscoverd', probeID, base64);
 | 
						|
  }
 | 
						|
 | 
						|
  public read(id: string): Observable<Infra> {
 | 
						|
    return this.rpcService.call<Infra>('InfraService.read', id);
 | 
						|
  }
 | 
						|
 | 
						|
  public readAllByProbeID(probeID: number): Observable<Infra[]> {
 | 
						|
    return this.rpcService.call<Infra[]>('InfraService.readAllByProbeID', probeID);
 | 
						|
  }
 | 
						|
 | 
						|
  public readAllByDomainID(domainID: number): Observable<Infra[]> {
 | 
						|
    return this.rpcService.call<Infra[]>('InfraService.readAllByDomainID', domainID);
 | 
						|
  }
 | 
						|
 | 
						|
  public readAllInfraZoneByProbeDomainID(probeDomainID: number): Observable<Infra[]> {
 | 
						|
    return this.rpcService.call<Infra[]>('InfraService.readAllInfraZoneByProbeDomainID', probeDomainID);
 | 
						|
  }
 | 
						|
 | 
						|
  public readAllByMetaInfraTypeKeyAndProbeID(metaInfraTypeKey: string, probeID: number): Observable<Infra[]> {
 | 
						|
    return this.rpcService.call<Infra[]>('InfraService.readAllByMetaInfraTypeKeyAndProbeID', metaInfraTypeKey, probeID);
 | 
						|
  }
 | 
						|
 | 
						|
}
 |