Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement deployment API support for ant-man and flash previews #960

Merged
merged 14 commits into from
Nov 25, 2020
Merged
45 changes: 45 additions & 0 deletions src/main/java/org/kohsuke/github/GHDeployment.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class GHDeployment extends GHObject {
protected String statuses_url;
protected String repository_url;
protected GHUser creator;
protected String original_environment;
protected boolean transient_environment;
protected boolean production_environment;

GHDeployment wrap(GHRepository owner) {
this.owner = owner;
Expand Down Expand Up @@ -89,6 +92,19 @@ public Object getPayloadObject() {
return payload;
}

/**
* The environment defined when the deployment was first created.
*
* @deprecated until preview feature has graduated to stable
*
* @return the original deployment environment
*/
@Deprecated
@Preview(Previews.FLASH)
marcoferrer marked this conversation as resolved.
Show resolved Hide resolved
public String getOriginalEnvironment() {
return original_environment;
}

/**
* Gets environment.
*
Expand All @@ -98,6 +114,33 @@ public String getEnvironment() {
return environment;
}

/**
* Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
* future.
*
* @deprecated until preview feature has graduated to stable
*
* @return the environment is transient
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public boolean isTransientEnvironment() {
return transient_environment;
}

/**
* Specifies if the given environment is one that end-users directly interact with.
*
* @deprecated until preview feature has graduated to stable
*
* @return the environment is used by end-users directly
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public boolean isProductionEnvironment() {
return production_environment;
}

/**
* Gets creator.
*
Expand Down Expand Up @@ -154,6 +197,8 @@ public GHDeploymentStatusBuilder createStatus(GHDeploymentState state) {
public PagedIterable<GHDeploymentStatus> listStatuses() {
return root.createRequest()
.withUrlPath(statuses_url)
.withPreview(Previews.ANT_MAN)
.withPreview(Previews.FLASH)
.toIterable(GHDeploymentStatus[].class, item -> item.wrap(owner));
}

Expand Down
48 changes: 47 additions & 1 deletion src/main/java/org/kohsuke/github/GHDeploymentBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public class GHDeploymentBuilder {
*/
public GHDeploymentBuilder(GHRepository repo) {
this.repo = repo;
this.builder = repo.root.createRequest().method("POST");
this.builder = repo.root.createRequest()
.withPreview(Previews.ANT_MAN)
.withPreview(Previews.FLASH)
.method("POST");
}

/**
Expand All @@ -40,6 +43,7 @@ public GHDeploymentBuilder(GHRepository repo, String ref) {
*
* @param branch
* the branch
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder ref(String branch) {
Expand All @@ -52,6 +56,7 @@ public GHDeploymentBuilder ref(String branch) {
*
* @param task
* the task
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder task(String task) {
Expand All @@ -64,6 +69,7 @@ public GHDeploymentBuilder task(String task) {
*
* @param autoMerge
* the auto merge
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder autoMerge(boolean autoMerge) {
Expand All @@ -76,6 +82,7 @@ public GHDeploymentBuilder autoMerge(boolean autoMerge) {
*
* @param requiredContexts
* the required contexts
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder requiredContexts(List<String> requiredContexts) {
Expand All @@ -88,6 +95,7 @@ public GHDeploymentBuilder requiredContexts(List<String> requiredContexts) {
*
* @param payload
* the payload
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder payload(String payload) {
Expand All @@ -100,18 +108,55 @@ public GHDeploymentBuilder payload(String payload) {
*
* @param environment
* the environment
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder environment(String environment) {
builder.with("environment", environment);
return this;
}

/**
* Specifies if the given environment is specific to the deployment and will no longer exist at some point in the
* future.
*
* @deprecated until preview feature has graduated to stable
*
* @param transientEnvironment
* the environment is transient
*
* @return the gh deployment builder
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public GHDeploymentBuilder transientEnvironment(boolean transientEnvironment) {
builder.with("transient_environment", transientEnvironment);
return this;
}

/**
* Specifies if the given environment is one that end-users directly interact with.
*
* @deprecated until preview feature has graduated to stable
*
* @param productionEnvironment
* the environment is used by end-users directly
*
* @return the gh deployment builder
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public GHDeploymentBuilder productionEnvironment(boolean productionEnvironment) {
builder.with("production_environment", productionEnvironment);
return this;
}

/**
* Description gh deployment builder.
*
* @param description
* the description
*
* @return the gh deployment builder
*/
public GHDeploymentBuilder description(String description) {
Expand All @@ -123,6 +168,7 @@ public GHDeploymentBuilder description(String description) {
* Create gh deployment.
*
* @return the gh deployment
*
* @throws IOException
* the io exception
*/
Expand Down
32 changes: 31 additions & 1 deletion src/main/java/org/kohsuke/github/GHDeploymentState.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,35 @@
* Represents the state of deployment
*/
public enum GHDeploymentState {
PENDING, SUCCESS, ERROR, FAILURE
PENDING,
SUCCESS,
ERROR,
FAILURE,

/**
* The state of the deployment currently reflects it's in progress.
*
* @deprecated until preview feature has graduated to stable
*/
@Deprecated
@Preview(Previews.FLASH)
IN_PROGRESS,

/**
* The state of the deployment currently reflects it's queued up for processing.
*
* @deprecated until preview feature has graduated to stable
*/
@Deprecated
@Preview(Previews.FLASH)
QUEUED,

/**
* The state of the deployment currently reflects it's no longer active.
*
* @deprecated until preview feature has graduated to stable
*/
@Deprecated
@Preview(Previews.ANT_MAN)
INACTIVE
}
34 changes: 34 additions & 0 deletions src/main/java/org/kohsuke/github/GHDeploymentStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ public class GHDeploymentStatus extends GHObject {
protected String state;
protected String description;
protected String target_url;
protected String log_url;
protected String deployment_url;
protected String repository_url;
protected String environment_url;

/**
* Wrap gh deployment status.
*
* @param owner
* the owner
*
* @return the gh deployment status
*/
public GHDeploymentStatus wrap(GHRepository owner) {
Expand All @@ -34,12 +37,30 @@ public GHDeploymentStatus wrap(GHRepository owner) {
/**
* Gets target url.
*
* @deprecated Target url is deprecated in favor of {@link #getLogUrl() getLogUrl}
*
* @return the target url
*/
@Deprecated
public URL getTargetUrl() {
return GitHubClient.parseURL(target_url);
}

/**
* Gets target url.
* <p>
* This method replaces {@link #getTargetUrl() getTargetUrl}}.
*
* @deprecated until preview feature has graduated to stable
*
* @return the target url
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public URL getLogUrl() {
return GitHubClient.parseURL(log_url);
}

/**
* Gets deployment url.
*
Expand All @@ -49,6 +70,19 @@ public URL getDeploymentUrl() {
return GitHubClient.parseURL(deployment_url);
}

/**
* Gets deployment environment url.
*
* @deprecated until preview feature has graduated to stable
*
* @return the deployment environment url
*/
@Deprecated
@Preview(Previews.ANT_MAN)
public URL getEnvironmentUrl() {
return GitHubClient.parseURL(environment_url);
}

/**
* Gets repository url.
*
Expand Down
Loading