
import { Injectable } from '@angular/core';
import { Observable } from "rxjs";
import { HttpClient } from "@angular/common/http";
import { ApiRequestService } from "src/app/services/api/api-request.service";

@Injectable({
  providedIn: 'root'
})
export class DataLakeSchedulerService {
  private baseURL = "scheduler";

  constructor(
    private http: HttpClient,
    private apiRequest: ApiRequestService,
  ) { }

  // Get job by lake ID
  getJobByLakeId(lakeId: number): Observable<any> {
    const _http = `${this.baseURL}/lake/${lakeId}`;
    return this.apiRequest.get(_http);
  }

  // Create a new job
  createJob(jobData: any): Observable<any> {
    const _http = `${this.baseURL}/create`;
    return this.apiRequest.post(_http, jobData);
  }

  // Pause a job
  pauseJob(jobId: number): Observable<any> {
    const _http = `${this.baseURL}/pause/${jobId}`;
    return this.apiRequest.post(_http, {});
  }

  // Resume a job
  resumeJob(jobId: number): Observable<any> {
    const _http = `${this.baseURL}/resume/${jobId}`;
    return this.apiRequest.post(_http, {});
  }

  // Stop a job
  stopJob(jobId: number): Observable<any> {
    const _http = `${this.baseURL}/stop/${jobId}`;
    return this.apiRequest.delete(_http);
  }
}