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 { IApiUserModel } from '../model/api-user.model';
import { IListQueryParams } from '@fleio-api/base-model/list-query-params';
import { Observable } from 'rxjs';
import { FleioObjectsList } from '@fleio-api/fleio-objects-list';
import { map } from 'rxjs/operators';
import { FleioId } from '@fleio-api/base-model/base-fleio-object.model';
import { IRegionModel } from '@fleio-api/openstack/model/region.model';

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

  getOpenRcFile(userName: string, defaultProjectId: FleioId, region: IRegionModel): Observable<any> {
    return this.postAction(
      'get_openrc_file_content',
      {
        user_name: userName,
        default_project_id: defaultProjectId,
        region,
      }
    );
  }
}
