All files / src/app/shared/api nfs.service.ts

100% Statements 41/41
75% Branches 6/8
100% Functions 15/15
100% Lines 38/38

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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