All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.chavaillaz.client.jenkins.okhttp.OkHttpPipelineApi Maven / Gradle / Ivy

package com.chavaillaz.client.jenkins.okhttp;

import java.util.concurrent.CompletableFuture;

import com.chavaillaz.client.jenkins.JenkinsAuthentication;
import com.chavaillaz.client.jenkins.api.PipelineApi;
import com.chavaillaz.client.jenkins.domain.folder.Path;
import com.chavaillaz.client.jenkins.domain.job.pipeline.Actions;
import com.chavaillaz.client.jenkins.domain.job.pipeline.Artifacts;
import com.chavaillaz.client.jenkins.domain.job.pipeline.Node;
import com.chavaillaz.client.jenkins.domain.job.pipeline.NodeLog;
import com.chavaillaz.client.jenkins.domain.job.pipeline.Run;
import com.chavaillaz.client.jenkins.domain.job.pipeline.Runs;
import okhttp3.OkHttpClient;

/**
 * Implementation of {@link PipelineApi} for OkHttp.
 */
public class OkHttpPipelineApi extends AbstractOkHttpClient implements PipelineApi {

    /**
     * Creates a new pipeline client based on OkHttp client.
     *
     * @param client         The OkHttp client to use
     * @param baseUrl        The URL of Jenkins
     * @param authentication The authentication method
     */
    public OkHttpPipelineApi(OkHttpClient client, String baseUrl, JenkinsAuthentication authentication) {
        super(client, baseUrl, authentication);
    }

    @Override
    public CompletableFuture getRunHistory(Path path, String pipelineName, String branchName) {
        return sendAsync(requestBuilder(URL_RUN_HISTORY, path, pipelineName, branchName).get(), Runs.class);
    }

    @Override
    public CompletableFuture getRun(Path path, String pipelineName, String branchName, long buildNumber) {
        return sendAsync(requestBuilder(URL_RUN_DETAILS, path, pipelineName, branchName, buildNumber).get(), Run.class);
    }

    @Override
    public CompletableFuture getRunPendingActions(Path path, String pipelineName, String branchName, long buildNumber) {
        return sendAsync(requestBuilder(URL_RUN_ACTIONS, path, pipelineName, branchName, buildNumber).get(), Actions.class);
    }

    @Override
    public CompletableFuture getRunArtifacts(Path path, String pipelineName, String branchName, long buildNumber) {
        return sendAsync(requestBuilder(URL_RUN_ARTIFACTS, path, pipelineName, branchName, buildNumber).get(), Artifacts.class);
    }

    @Override
    public CompletableFuture getRunNode(Path path, String pipelineName, String branchName, long buildNumber, String nodeId) {
        return sendAsync(requestBuilder(URL_RUN_STAGE_DETAILS, path, pipelineName, branchName, buildNumber, nodeId).get(), Node.class);
    }

    @Override
    public CompletableFuture getRunNodeLog(Path path, String pipelineName, String branchName, long buildNumber, String nodeId) {
        return sendAsync(requestBuilder(URL_RUN_STAGE_LOGS, path, pipelineName, branchName, buildNumber, nodeId).get(), NodeLog.class);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy