]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts
import 15.2.1 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / cephfs.service.ts
CommitLineData
9f95a23c 1import { HttpClient, HttpParams } from '@angular/common/http';
11fdf7f2
TL
2import { Injectable } from '@angular/core';
3
9f95a23c
TL
4import * as _ from 'lodash';
5import { Observable } from 'rxjs';
6
7import { cdEncode } from '../decorators/cd-encode';
8import { CephfsDir, CephfsQuotas } from '../models/cephfs-directory-models';
11fdf7f2
TL
9import { ApiModule } from './api.module';
10
9f95a23c 11@cdEncode
11fdf7f2
TL
12@Injectable({
13 providedIn: ApiModule
14})
15export class CephfsService {
16 baseURL = 'api/cephfs';
9f95a23c 17 baseUiURL = 'ui-api/cephfs';
11fdf7f2
TL
18
19 constructor(private http: HttpClient) {}
20
21 list() {
22 return this.http.get(`${this.baseURL}`);
23 }
24
9f95a23c
TL
25 lsDir(id: number, path?: string): Observable<CephfsDir[]> {
26 let apiPath = `${this.baseUiURL}/${id}/ls_dir?depth=2`;
27 if (path) {
28 apiPath += `&path=${encodeURIComponent(path)}`;
29 }
30 return this.http.get<CephfsDir[]>(apiPath);
31 }
32
33 getCephfs(id: number) {
11fdf7f2
TL
34 return this.http.get(`${this.baseURL}/${id}`);
35 }
36
9f95a23c
TL
37 getTabs(id: number) {
38 return this.http.get(`ui-api/cephfs/${id}/tabs`);
39 }
40
41 getClients(id: number) {
11fdf7f2
TL
42 return this.http.get(`${this.baseURL}/${id}/clients`);
43 }
44
9f95a23c
TL
45 evictClient(fsId: number, clientId: number) {
46 return this.http.delete(`${this.baseURL}/${fsId}/client/${clientId}`);
47 }
48
49 getMdsCounters(id: string) {
11fdf7f2
TL
50 return this.http.get(`${this.baseURL}/${id}/mds_counters`);
51 }
9f95a23c
TL
52
53 mkSnapshot(id: number, path: string, name?: string) {
54 let params = new HttpParams();
55 params = params.append('path', path);
56 if (!_.isUndefined(name)) {
57 params = params.append('name', name);
58 }
59 return this.http.post(`${this.baseURL}/${id}/mk_snapshot`, null, { params });
60 }
61
62 rmSnapshot(id: number, path: string, name: string) {
63 let params = new HttpParams();
64 params = params.append('path', path);
65 params = params.append('name', name);
66 return this.http.post(`${this.baseURL}/${id}/rm_snapshot`, null, { params });
67 }
68
69 updateQuota(id: number, path: string, quotas: CephfsQuotas) {
70 let params = new HttpParams();
71 params = params.append('path', path);
72 return this.http.post(`${this.baseURL}/${id}/set_quotas`, quotas, {
73 observe: 'response',
74 params
75 });
76 }
11fdf7f2 77}