1 import { HttpClient } from '@angular/common/http';
2 import { Injectable } from '@angular/core';
4 import { Observable } from 'rxjs';
5 import { map } from 'rxjs/operators';
7 import { cdEncode } from '../decorators/cd-encode';
8 import { RbdConfigurationEntry } from '../models/configuration';
9 import { RbdConfigurationService } from '../services/rbd-configuration.service';
10 import { ApiModule } from './api.module';
16 export class PoolService {
19 constructor(private http: HttpClient, private rbdConfigurationService: RbdConfigurationService) {}
22 return this.http.post(this.apiPath, pool, { observe: 'response' });
27 if (pool.hasOwnProperty('srcpool')) {
34 return this.http.put(`${this.apiPath}/${encodeURIComponent(name)}`, pool, {
39 delete(name: string) {
40 return this.http.delete(`${this.apiPath}/${name}`, { observe: 'response' });
43 get(poolName: string) {
44 return this.http.get(`${this.apiPath}/${poolName}`);
48 return this.http.get(`${this.apiPath}?stats=true`);
51 getConfiguration(poolName: string): Observable<RbdConfigurationEntry[]> {
52 return this.http.get<RbdConfigurationEntry[]>(`${this.apiPath}/${poolName}/configuration`).pipe(
53 // Add static data maintained in RbdConfigurationService
56 Object.assign(entry, this.rbdConfigurationService.getOptionByName(entry.name))
63 return this.http.get(`ui-${this.apiPath}/info`);
66 list(attrs: string[] = []) {
67 const attrsStr = attrs.join(',');
69 .get(`${this.apiPath}?attrs=${attrsStr}`)
71 .then((resp: any) => {