import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { ApiRequestService } from '../api/api-request.service';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class AdditionalcontainerService {
  // baseurl = environment.sureops;
  baseurl = environment.backendUrl;

  private baseURL = "Gaurav_testing/Gaurav_testing";
  constructor(private apiRequest: ApiRequestService,
    private _http: HttpClient,) { }


  saveData(data: any): Observable<any> {
    const url = `${this.baseurl}/sureops/Additional_container/Additional_container`;
    return this._http.post(url, data);
  }

  getDetails(): Observable<any> {
    const url = `${this.baseurl}/sureops/Additional_container/Additional_container`;
    return this._http.get(url);
  }

  getDetailsById(id: number): Observable<any> {
    const url = `${this.baseurl}/sureops/Additional_container/Additional_container/${id}`;
    return this._http.get(url);
  }

  deleteById(id: number): Observable<any> {
    const url = `${this.baseurl}/sureops/Additional_container/Additional_container/${id}`;
    return this._http.delete(url);
  }

  update(data: any, id: number): Observable<any> {
    const url = `${this.baseurl}/sureops/Additional_container/Additional_container/${id}`;
    return this._http.put(url, data);
  }

  ///copy ADDITIONAL CONTAINER TO CREATE DEPLOYMENT
  public copyToCreateDeployment(projId: number, profileId: number, service: string): Observable<any> {
    const url = `${this.baseurl}/sureops/Additional_container/copt_to_deployment/${projId}/${profileId}/${service}`;
    return this._http.get(url);
  }
  //	get all by project id and profile id
  getAllContainers(projId: number, profileId: number): Observable<any> {
    const url = `${this.baseurl}/sureops/Additional_container/copt_to_deployment/${projId}/${profileId}`;
    return this._http.get(url);
  }



  /////////////////////////////////////

  getAll(page?: number, size?: number): Observable<any> {
    return this.apiRequest.get(this.baseURL);
  }
  getById(id: number): Observable<any> {
    const _http = this.baseURL + "/" + id;
    return this.apiRequest.get(_http);
  }
  create(data: any): Observable<any> {
    return this.apiRequest.post(this.baseURL, data);
  }
  updategaurav(id: number, data: any): Observable<any> {
    const _http = this.baseURL + "/" + id;
    return this.apiRequest.put(_http, data);
  }
  delete(id: number): Observable<any> {
    const _http = this.baseURL + "/" + id;
    return this.apiRequest.delete(_http);
  }
}
