]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / host.service.ts
CommitLineData
11fdf7f2
TL
1import { HttpClient } from '@angular/common/http';
2import { Injectable } from '@angular/core';
3
9f95a23c
TL
4import { Observable } from 'rxjs';
5import { map } from 'rxjs/operators';
6
7import { Daemon } from '../models/daemon.interface';
8import { CdDevice } from '../models/devices';
9import { SmartDataResponseV1 } from '../models/smart';
10import { DeviceService } from '../services/device.service';
11fdf7f2
TL
11import { ApiModule } from './api.module';
12
13@Injectable({
14 providedIn: ApiModule
15})
16export class HostService {
9f95a23c
TL
17 baseURL = 'api/host';
18
19 constructor(private http: HttpClient, private deviceService: DeviceService) {}
11fdf7f2
TL
20
21 list() {
9f95a23c
TL
22 return this.http.get(this.baseURL);
23 }
24
25 create(hostname: string) {
26 return this.http.post(this.baseURL, { hostname: hostname }, { observe: 'response' });
27 }
28
29 delete(hostname: string) {
30 return this.http.delete(`${this.baseURL}/${hostname}`, { observe: 'response' });
31 }
32
33 getDevices(hostname: string): Observable<CdDevice[]> {
11fdf7f2 34 return this.http
9f95a23c
TL
35 .get<CdDevice[]>(`${this.baseURL}/${hostname}/devices`)
36 .pipe(map((devices) => devices.map((device) => this.deviceService.prepareDevice(device))));
37 }
38
39 getSmartData(hostname: string) {
40 return this.http.get<SmartDataResponseV1>(`${this.baseURL}/${hostname}/smart`);
41 }
42
43 getDaemons(hostname: string): Observable<Daemon[]> {
44 return this.http.get<Daemon[]>(`${this.baseURL}/${hostname}/daemons`);
11fdf7f2
TL
45 }
46}