1 import { catchError, map } from 'rxjs/operators'
2 import { HttpClient } from '@angular/common/http'
3 import { Injectable } from '@angular/core'
4 import { RestExtractor, RestService } from '@app/shared'
5 import { environment } from '../../../../environments/environment'
8 export class RedundancyService {
9 static BASE_USER_SUBSCRIPTIONS_URL = environment.apiUrl + '/api/v1/server/redundancy'
12 private authHttp: HttpClient,
13 private restExtractor: RestExtractor,
14 private restService: RestService
17 updateRedundancy (host: string, redundancyAllowed: boolean) {
18 const url = RedundancyService.BASE_USER_SUBSCRIPTIONS_URL + '/' + host
20 const body = { redundancyAllowed }
22 return this.authHttp.put(url, body)
24 map(this.restExtractor.extractDataBool),
25 catchError(err => this.restExtractor.handleError(err))