import { Injectable } from '@angular/core';
import { ConfigService } from '@shared/config/config.service';
import { FleioApiService } from '../../fleio-api.service';
import { HttpClient } from '@angular/common/http';
import { IRegionModel } from '../model/region.model';
import { Observable } from 'rxjs';
import { FleioObjectsList } from '@fleio-api/fleio-objects-list';

@Injectable({
  providedIn: 'root'
})
export class RegionsApiService extends FleioApiService<IRegionModel> {
  constructor(protected httpClient: HttpClient, protected config: ConfigService) {
    super();
    this.setEndpoint(config.getPanelApiUrl('openstack/regions'));
  }

  getAllRegions(): Observable<FleioObjectsList<IRegionModel>> {
    return this.getAction('all_regions',);
  }

  updateRegions(regions: IRegionModel[]): Observable<any> {
    return this.postAction('update_regions', regions);
  }
}
