]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/nfs.service.ts
Import ceph 15.2.8
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / nfs.service.ts
1 import { HttpClient } from '@angular/common/http';
2 import { Injectable } from '@angular/core';
3
4 import { I18n } from '@ngx-translate/i18n-polyfill';
5
6 import { ApiModule } from './api.module';
7
8 @Injectable({
9 providedIn: ApiModule
10 })
11 export class NfsService {
12 apiPath = 'api/nfs-ganesha';
13 uiApiPath = 'ui-api/nfs-ganesha';
14
15 nfsAccessType = [
16 {
17 value: 'RW',
18 help: this.i18n('Allows all operations')
19 },
20 {
21 value: 'RO',
22 help: this.i18n('Allows only operations that do not modify the server')
23 },
24 {
25 value: 'MDONLY',
26 help: this.i18n('Does not allow read or write operations, but allows any other operation')
27 },
28 {
29 value: 'MDONLY_RO',
30 help: this.i18n(
31 'Does not allow read, write, or any operation that modifies file \
32 attributes or directory content'
33 )
34 },
35 {
36 value: 'NONE',
37 help: this.i18n('Allows no access at all')
38 }
39 ];
40
41 nfsFsal = [
42 {
43 value: 'CEPH',
44 descr: this.i18n('CephFS')
45 },
46 {
47 value: 'RGW',
48 descr: this.i18n('Object Gateway')
49 }
50 ];
51
52 nfsSquash = ['no_root_squash', 'root_id_squash', 'root_squash', 'all_squash'];
53
54 constructor(private http: HttpClient, private i18n: I18n) {}
55
56 list() {
57 return this.http.get(`${this.apiPath}/export`);
58 }
59
60 get(clusterId: string, exportId: string) {
61 return this.http.get(`${this.apiPath}/export/${clusterId}/${exportId}`);
62 }
63
64 create(nfs: any) {
65 return this.http.post(`${this.apiPath}/export`, nfs, { observe: 'response' });
66 }
67
68 update(clusterId: string, id: string, nfs: any) {
69 return this.http.put(`${this.apiPath}/export/${clusterId}/${id}`, nfs, { observe: 'response' });
70 }
71
72 delete(clusterId: string, exportId: string) {
73 return this.http.delete(`${this.apiPath}/export/${clusterId}/${exportId}`, {
74 observe: 'response'
75 });
76 }
77
78 lsDir(fs_name: string, root_dir: string) {
79 return this.http.get(`${this.uiApiPath}/lsdir/${fs_name}?root_dir=${root_dir}`);
80 }
81
82 buckets(user_id: string) {
83 return this.http.get(`${this.uiApiPath}/rgw/buckets?user_id=${user_id}`);
84 }
85
86 clients() {
87 return this.http.get(`${this.uiApiPath}/cephx/clients`);
88 }
89
90 fsals() {
91 return this.http.get(`${this.uiApiPath}/fsals`);
92 }
93
94 filesystems() {
95 return this.http.get(`${this.uiApiPath}/cephfs/filesystems`);
96 }
97
98 daemon() {
99 return this.http.get(`${this.apiPath}/daemon`);
100 }
101
102 start(host_name: string) {
103 return this.http.put(`${this.apiPath}/service/${host_name}/start`, null, {
104 observe: 'response'
105 });
106 }
107
108 stop(host_name: string) {
109 return this.http.put(`${this.apiPath}/service/${host_name}/stop`, null, {
110 observe: 'response'
111 });
112 }
113 }