1 import { HttpClient } from '@angular/common/http';
2 import { Injectable } from '@angular/core';
4 import { Observable, throwError } from 'rxjs';
6 import { NfsFSAbstractionLayer } from '~/app/ceph/nfs/models/nfs.fsal';
7 import { ApiClient } from '~/app/shared/api/api-client';
9 export interface Directory {
16 export class NfsService extends ApiClient {
17 apiPath = 'api/nfs-ganesha';
18 uiApiPath = 'ui-api/nfs-ganesha';
23 help: $localize`Allows all operations`
27 help: $localize`Allows only operations that do not modify the server`
31 help: $localize`Allows no access at all`
35 nfsFsal: NfsFSAbstractionLayer[] = [
38 descr: $localize`CephFS`,
43 descr: $localize`Object Gateway`,
48 nfsSquash = ['no_root_squash', 'root_id_squash', 'root_squash', 'all_squash'];
50 constructor(private http: HttpClient) {
55 return this.http.get(`${this.apiPath}/export`);
58 get(clusterId: string, exportId: string) {
59 return this.http.get(`${this.apiPath}/export/${clusterId}/${exportId}`);
63 return this.http.post(`${this.apiPath}/export`, nfs, {
64 headers: { Accept: this.getVersionHeaderValue(2, 0) },
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) },
76 delete(clusterId: string, exportId: string) {
77 return this.http.delete(`${this.apiPath}/export/${clusterId}/${exportId}`, {
78 headers: { Accept: this.getVersionHeaderValue(2, 0) },
84 return this.http.get(`${this.apiPath}/cluster`, {
85 headers: { Accept: this.getVersionHeaderValue(0, 1) }
89 lsDir(fs_name: string, root_dir: string): Observable<Directory> {
91 return throwError($localize`Please specify a filesystem volume.`);
93 return this.http.get<Directory>(`${this.uiApiPath}/lsdir/${fs_name}?root_dir=${root_dir}`);
97 return this.http.get(`${this.uiApiPath}/fsals`);
101 return this.http.get(`${this.uiApiPath}/cephfs/filesystems`);