]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/nfs.service.ts
import ceph 16.2.7
[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 { Observable, throwError } from 'rxjs';
5
6 import { NfsFSAbstractionLayer } from '~/app/ceph/nfs/models/nfs.fsal';
7 import { ApiClient } from '~/app/shared/api/api-client';
8
9 export interface Directory {
10 paths: string[];
11 }
12
13 @Injectable({
14 providedIn: 'root'
15 })
16 export class NfsService extends ApiClient {
17 apiPath = 'api/nfs-ganesha';
18 uiApiPath = 'ui-api/nfs-ganesha';
19
20 nfsAccessType = [
21 {
22 value: 'RW',
23 help: $localize`Allows all operations`
24 },
25 {
26 value: 'RO',
27 help: $localize`Allows only operations that do not modify the server`
28 },
29 {
30 value: 'NONE',
31 help: $localize`Allows no access at all`
32 }
33 ];
34
35 nfsFsal: NfsFSAbstractionLayer[] = [
36 {
37 value: 'CEPH',
38 descr: $localize`CephFS`,
39 disabled: false
40 },
41 {
42 value: 'RGW',
43 descr: $localize`Object Gateway`,
44 disabled: false
45 }
46 ];
47
48 nfsSquash = ['no_root_squash', 'root_id_squash', 'root_squash', 'all_squash'];
49
50 constructor(private http: HttpClient) {
51 super();
52 }
53
54 list() {
55 return this.http.get(`${this.apiPath}/export`);
56 }
57
58 get(clusterId: string, exportId: string) {
59 return this.http.get(`${this.apiPath}/export/${clusterId}/${exportId}`);
60 }
61
62 create(nfs: any) {
63 return this.http.post(`${this.apiPath}/export`, nfs, {
64 headers: { Accept: this.getVersionHeaderValue(2, 0) },
65 observe: 'response'
66 });
67 }
68
69 update(clusterId: string, id: number, nfs: any) {
70 return this.http.put(`${this.apiPath}/export/${clusterId}/${id}`, nfs, {
71 headers: { Accept: this.getVersionHeaderValue(2, 0) },
72 observe: 'response'
73 });
74 }
75
76 delete(clusterId: string, exportId: string) {
77 return this.http.delete(`${this.apiPath}/export/${clusterId}/${exportId}`, {
78 headers: { Accept: this.getVersionHeaderValue(2, 0) },
79 observe: 'response'
80 });
81 }
82
83 listClusters() {
84 return this.http.get(`${this.apiPath}/cluster`, {
85 headers: { Accept: this.getVersionHeaderValue(0, 1) }
86 });
87 }
88
89 lsDir(fs_name: string, root_dir: string): Observable<Directory> {
90 if (!fs_name) {
91 return throwError($localize`Please specify a filesystem volume.`);
92 }
93 return this.http.get<Directory>(`${this.uiApiPath}/lsdir/${fs_name}?root_dir=${root_dir}`);
94 }
95
96 fsals() {
97 return this.http.get(`${this.uiApiPath}/fsals`);
98 }
99
100 filesystems() {
101 return this.http.get(`${this.uiApiPath}/cephfs/filesystems`);
102 }
103 }