]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts
update ceph source to reef 18.2.1
[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
f67539c2 4import _ from 'lodash';
9f95a23c
TL
5import { Observable } from 'rxjs';
6
7import { cdEncode } from '../decorators/cd-encode';
8import { CephfsDir, CephfsQuotas } from '../models/cephfs-directory-models';
11fdf7f2 9
9f95a23c 10@cdEncode
11fdf7f2 11@Injectable({
f67539c2 12 providedIn: 'root'
11fdf7f2
TL
13})
14export class CephfsService {
15 baseURL = 'api/cephfs';
9f95a23c 16 baseUiURL = 'ui-api/cephfs';
11fdf7f2
TL
17
18 constructor(private http: HttpClient) {}
19
20 list() {
21 return this.http.get(`${this.baseURL}`);
22 }
23
9f95a23c
TL
24 lsDir(id: number, path?: string): Observable<CephfsDir[]> {
25 let apiPath = `${this.baseUiURL}/${id}/ls_dir?depth=2`;
26 if (path) {
27 apiPath += `&path=${encodeURIComponent(path)}`;
28 }
29 return this.http.get<CephfsDir[]>(apiPath);
30 }
31
32 getCephfs(id: number) {
11fdf7f2
TL
33 return this.http.get(`${this.baseURL}/${id}`);
34 }
35
9f95a23c
TL
36 getTabs(id: number) {
37 return this.http.get(`ui-api/cephfs/${id}/tabs`);
38 }
39
40 getClients(id: number) {
11fdf7f2
TL
41 return this.http.get(`${this.baseURL}/${id}/clients`);
42 }
43
9f95a23c
TL
44 evictClient(fsId: number, clientId: number) {
45 return this.http.delete(`${this.baseURL}/${fsId}/client/${clientId}`);
46 }
47
48 getMdsCounters(id: string) {
11fdf7f2
TL
49 return this.http.get(`${this.baseURL}/${id}/mds_counters`);
50 }
9f95a23c
TL
51
52 mkSnapshot(id: number, path: string, name?: string) {
53 let params = new HttpParams();
54 params = params.append('path', path);
55 if (!_.isUndefined(name)) {
56 params = params.append('name', name);
57 }
f67539c2 58 return this.http.post(`${this.baseURL}/${id}/snapshot`, null, { params });
9f95a23c
TL
59 }
60
61 rmSnapshot(id: number, path: string, name: string) {
62 let params = new HttpParams();
63 params = params.append('path', path);
64 params = params.append('name', name);
f67539c2 65 return this.http.delete(`${this.baseURL}/${id}/snapshot`, { params });
9f95a23c
TL
66 }
67
f67539c2 68 quota(id: number, path: string, quotas: CephfsQuotas) {
9f95a23c
TL
69 let params = new HttpParams();
70 params = params.append('path', path);
f67539c2 71 return this.http.put(`${this.baseURL}/${id}/quota`, quotas, {
9f95a23c
TL
72 observe: 'response',
73 params
74 });
75 }
aee94f69
TL
76
77 create(name: string, serviceSpec: object) {
78 return this.http.post(
79 this.baseURL,
80 { name: name, service_spec: serviceSpec },
81 {
82 observe: 'response'
83 }
84 );
85 }
86
87 isCephFsPool(pool: any) {
88 return _.indexOf(pool.application_metadata, 'cephfs') !== -1 && !pool.pool_name.includes('/');
89 }
90
91 remove(name: string) {
92 return this.http.delete(`${this.baseURL}/remove/${name}`, {
93 observe: 'response'
94 });
95 }
96
97 rename(vol_name: string, new_vol_name: string) {
98 let requestBody = {
99 name: vol_name,
100 new_name: new_vol_name
101 };
102 return this.http.put(`${this.baseURL}/rename`, requestBody, {
103 observe: 'response'
104 });
105 }
11fdf7f2 106}