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.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 Map headers;
public ApiEndpoint(String appName, String stackName, String commit, String encodedApiKey) {
this.appName = appName;
this.stackName = stackName;
this.commit = commit;
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 {
if (blobUrl == null) {
throw new IllegalStateException("Slug must be created before uploading!");
}
RestClient.put(blobUrl, slugFile, listener);
}
public String getBlobUrl() { return blobUrl; }
public String getStackName() { return stackName; }
public String getCommit() { return commit; }
}