
com.heroku.sdk.deploy.endpoints.ApiEndpoint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of heroku-deploy Show documentation
Show all versions of heroku-deploy Show documentation
Library for deploying Java applications to Heroku
package com.heroku.sdk.deploy.endpoints;
import com.heroku.sdk.deploy.utils.Curl;
import com.heroku.sdk.deploy.utils.Logger;
import com.heroku.sdk.deploy.utils.RestClient;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public abstract class ApiEndpoint {
public static final String BASE_URL = "https://api.heroku.com";
protected String blobUrl;
protected String stackName;
protected String appName;
protected String commit;
protected Boolean useCurl;
protected Map headers;
public ApiEndpoint(String appName, String stackName, String commit, String encodedApiKey) {
this.appName = appName;
this.stackName = stackName;
this.commit = commit;
this.useCurl = "true".equals(System.getProperty("heroku.curl.enabled", "false"));
headers = new HashMap();
headers.put("Authorization", encodedApiKey);
headers.put("Content-Type", "application/json");
headers.put("Accept", "application/vnd.heroku+json; version=3");
}
public void upload(File slugFile, Logger listener) throws IOException, InterruptedException {
if (blobUrl == null) {
throw new IllegalStateException("Slug must be created before uploading!");
}
if (useCurl) {
listener.logDebug("Uploading with curl");
Curl.put(blobUrl, slugFile);
} else {
RestClient.put(blobUrl, slugFile, listener);
}
}
public String getBlobUrl() { return blobUrl; }
public String getStackName() { return stackName; }
public String getCommit() { return commit; }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy