
org.sourcelab.github.client.request.RerunWorkflowOptionsBuilder Maven / Gradle / Ivy
The newest version!
package org.sourcelab.github.client.request;
import org.sourcelab.github.client.exception.BuilderValidationException;
import org.sourcelab.github.client.utils.UrlParser;
public final class RerunWorkflowOptionsBuilder {
private String owner = null;
private String repo = null;
private Long runId = null;
private Boolean enableDebugLogging;
/**
* Parse from WorkflowRun.rerun_url property.
*/
public RerunWorkflowOptionsBuilder fromRerunUrl(final String rerunUrl) {
UrlParser.JobsUrlBits bits = null;
try {
bits = UrlParser.parseJobsRerunUrl(rerunUrl);
} catch (Exception e) {
throw new BuilderValidationException("Unable to parse jobsUrl: " + rerunUrl, e);
}
if (bits == null) {
throw new BuilderValidationException("Unable to parse jobsUrl: " + rerunUrl);
}
this
.withOwner(bits.getOwner())
.withRepo(bits.getRepo())
.withRunId(bits.getRunId());
return this;
}
public RerunWorkflowOptionsBuilder withOwner(final String owner) {
this.owner = owner;
return this;
}
public RerunWorkflowOptionsBuilder withRepo(final String repo) {
this.repo = repo;
return this;
}
public RerunWorkflowOptionsBuilder withRunId(final long runId) {
this.runId = runId;
return this;
}
public RerunWorkflowOptionsBuilder withEnableDebugLogging(final boolean enableDebugLogging) {
this.enableDebugLogging = enableDebugLogging;
return this;
}
/**
* Create new instance from builder.
* @return Create new instance from builder.
*/
public RerunWorkflowOptions build() {
if (owner == null) {
throw new BuilderValidationException("owner property is required.");
}
if (repo == null) {
throw new BuilderValidationException("repo property is required.");
}
if (runId == null) {
throw new BuilderValidationException("runId property is required.");
}
return new RerunWorkflowOptions(owner, repo, runId, enableDebugLogging);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy