]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs-subvolume.service.ts
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / cephfs-subvolume.service.ts
CommitLineData
aee94f69
TL
1import { HttpClient } from '@angular/common/http';
2import { Injectable } from '@angular/core';
3import { CephfsSubvolume } from '../models/cephfs-subvolume.model';
4import { Observable, of } from 'rxjs';
5import { catchError, mapTo } from 'rxjs/operators';
6import _ from 'lodash';
7
8@Injectable({
9 providedIn: 'root'
10})
11export class CephfsSubvolumeService {
12 baseURL = 'api/cephfs/subvolume';
13
14 constructor(private http: HttpClient) {}
15
16 get(fsName: string, subVolumeGroupName: string = ''): Observable<CephfsSubvolume[]> {
17 return this.http.get<CephfsSubvolume[]>(`${this.baseURL}/${fsName}`, {
18 params: {
19 group_name: subVolumeGroupName
20 }
21 });
22 }
23
24 create(
25 fsName: string,
26 subVolumeName: string,
27 subVolumeGroupName: string,
28 poolName: string,
29 size: string,
30 uid: number,
31 gid: number,
32 mode: string,
33 namespace: boolean
34 ) {
35 return this.http.post(
36 this.baseURL,
37 {
38 vol_name: fsName,
39 subvol_name: subVolumeName,
40 group_name: subVolumeGroupName,
41 pool_layout: poolName,
42 size: size,
43 uid: uid,
44 gid: gid,
45 mode: mode,
46 namespace_isolated: namespace
47 },
48 { observe: 'response' }
49 );
50 }
51
52 info(fsName: string, subVolumeName: string, subVolumeGroupName: string = '') {
53 return this.http.get(`${this.baseURL}/${fsName}/info`, {
54 params: {
55 subvol_name: subVolumeName,
56 group_name: subVolumeGroupName
57 }
58 });
59 }
60
61 remove(
62 fsName: string,
63 subVolumeName: string,
64 subVolumeGroupName: string = '',
65 retainSnapshots: boolean = false
66 ) {
67 return this.http.delete(`${this.baseURL}/${fsName}`, {
68 params: {
69 subvol_name: subVolumeName,
70 group_name: subVolumeGroupName,
71 retain_snapshots: retainSnapshots
72 },
73 observe: 'response'
74 });
75 }
76
77 exists(subVolumeName: string, fsName: string) {
78 return this.info(fsName, subVolumeName).pipe(
79 mapTo(true),
80 catchError((error: Event) => {
81 if (_.isFunction(error.preventDefault)) {
82 error.preventDefault();
83 }
84 return of(false);
85 })
86 );
87 }
88
89 update(fsName: string, subVolumeName: string, size: string, subVolumeGroupName: string = '') {
90 return this.http.put(`${this.baseURL}/${fsName}`, {
91 subvol_name: subVolumeName,
92 size: size,
93 group_name: subVolumeGroupName
94 });
95 }
96}