package com.microservices.pms.pipeline.service;

import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.web.page.GenericsTableDataInfo;
import com.microservices.pms.pipeline.domain.PmsCiPipelines;
import com.microservices.pms.pipeline.domain.vo.*;

import javax.servlet.http.HttpServletResponse;

/**
 * 流水线Service接口
 * 
 * @author wanjia
 * @date 2024-03-02
 */
public interface IPmsCiPipelinesService 
{
    /**
     * 查询流水线
     * 
     * @param id 流水线主键
     * @return 流水线
     */
    public PmsCiPipelinesDetailVo selectPmsCiPipelinesById(Long id);

    /**
     * 查询流水线列表
     *
     * @param enterpriseIdentifier
     * @param pipelineName         流水线名
     * @param pipelineType
     * @return 流水线集合
     */
    public GenericsTableDataInfo<PmsCiPipelinesDetailVo> selectPmsCiPipelinesList(String enterpriseIdentifier, String pipelineName, Integer pipelineType);

    /**
     * 新增流水线
     * 
     * @param pmsCiPipelinesInputVo 流水线输入
     * @return 结果
     */
    public JSONObject insertPmsCiPipelines(PmsCiPipelinesInputVo pmsCiPipelinesInputVo, String enterpriseIdentifier);

    /**
     * 修改流水线
     * 
     * @param pmsCiPipelines 流水线
     * @return 结果
     */
    public int updatePmsCiPipelines(PmsCiPipelines pmsCiPipelines);

    /**
     * 批量删除流水线
     * 
     * @param ids 需要删除的流水线主键集合
     * @return 结果
     */
    public int deletePmsCiPipelinesByIds(Long[] ids);

    /**
     * 删除流水线信息
     * 
     * @param id 流水线主键
     * @return 结果
     */
    public int deletePmsCiPipelinesById(Long id);

    /**
     * 创建或更新流水线文件（存在则更新，不存在则创建）
     *
     * @param pmsCiPipelineFileInputVo
     * @return 结果
     */
    int createOrUpdatePmsCiPipelineFile(PmsCiPipelineFileInputVo pmsCiPipelineFileInputVo);

    JSONObject selectPipelineFileList(Long id);

    JSONObject selectPipelineRunsList(Long id, PmsCiPipelinePageVo pmsCiPipelinePageVo);

    JSONObject getPipelineRunsJob(Long id, String run, String job, PmsCiPipelineLogCursorsVo pmsCiPipelineLogCursorsVo);

    JSONObject enablePipeline(Long id);

    JSONObject disablePipeline(Long id);

    JSONObject selectNodes();

    JSONObject selectTemplates();

    JSONObject buildPipelineYamlByGraphJson(Long id, PmsCiPipelineBuildYamlInputVo pmsCiPipelineBuildInputVo);

    JSONObject savePipelineYamlByGraphicJson(Long id, PmsCiPipelineBuildYamlInputVo pmsCiPipelineBuildInputVo);

    JSONObject reRunPipelineRunsJob(Long id, String run, String job);

    JSONObject reRunAllJobsInPipelineRun(Long id, String run);

    void getPipelineRunJobLogs(Long id, String run, String job, HttpServletResponse response);

    JSONObject runPipelineRunsJob(Long id, String workflow, String ref);
}
