1 import { HttpClient } from '@angular/common/http';
2 import { Injectable } from '@angular/core';
4 import { ConfigFormCreateRequestModel } from '../../ceph/cluster/configuration/configuration-form/configuration-form-create-request.model';
5 import { ApiModule } from './api.module';
10 export class ConfigurationService {
11 constructor(private http: HttpClient) {}
13 private findValue(config: any, section: string) {
17 return config.value.find((v: any) => v.section === section);
20 getValue(config: any, section: string) {
21 let val = this.findValue(config, section);
23 const indexOfDot = section.indexOf('.');
24 if (indexOfDot !== -1) {
25 val = this.findValue(config, section.substring(0, indexOfDot));
29 val = this.findValue(config, 'global');
34 return config.default;
38 return this.http.get('api/cluster_conf/');
41 get(configOption: string) {
42 return this.http.get(`api/cluster_conf/${configOption}`);
45 filter(configOptionNames: Array<string>) {
46 return this.http.get(`api/cluster_conf/filter?names=${configOptionNames.join(',')}`);
49 create(configOption: ConfigFormCreateRequestModel) {
50 return this.http.post('api/cluster_conf/', configOption);
53 delete(configOption: string, section: string) {
54 return this.http.delete(`api/cluster_conf/${configOption}?section=${section}`);
57 bulkCreate(configOptions: object) {
58 return this.http.put('api/cluster_conf/', configOptions);