]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/ceph-service.service.ts
import ceph 16.2.6
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / ceph-service.service.ts
CommitLineData
9f95a23c
TL
1import { HttpClient, HttpParams } from '@angular/common/http';
2import { Injectable } from '@angular/core';
3
4import { Observable } from 'rxjs';
5
6import { Daemon } from '../models/daemon.interface';
1911f103 7import { CephServiceSpec } from '../models/service.interface';
9f95a23c
TL
8
9@Injectable({
f67539c2 10 providedIn: 'root'
9f95a23c
TL
11})
12export class CephServiceService {
13 private url = 'api/service';
14
15 constructor(private http: HttpClient) {}
16
1911f103 17 list(serviceName?: string): Observable<CephServiceSpec[]> {
9f95a23c
TL
18 const options = serviceName
19 ? { params: new HttpParams().set('service_name', serviceName) }
20 : {};
1911f103 21 return this.http.get<CephServiceSpec[]>(this.url, options);
9f95a23c
TL
22 }
23
24 getDaemons(serviceName?: string): Observable<Daemon[]> {
25 return this.http.get<Daemon[]>(`${this.url}/${serviceName}/daemons`);
26 }
adb31ebb
TL
27
28 create(serviceSpec: { [key: string]: any }) {
29 const serviceName = serviceSpec['service_id']
30 ? `${serviceSpec['service_type']}.${serviceSpec['service_id']}`
31 : serviceSpec['service_type'];
32 return this.http.post(
33 this.url,
34 {
35 service_name: serviceName,
36 service_spec: serviceSpec
37 },
38 { observe: 'response' }
39 );
40 }
41
42 delete(serviceName: string) {
43 return this.http.delete(`${this.url}/${serviceName}`, { observe: 'response' });
44 }
45
46 getKnownTypes(): Observable<string[]> {
47 return this.http.get<string[]>(`${this.url}/known_types`);
48 }
9f95a23c 49}