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

com.heroku.sdk.deploy.endpoints.ApiEndpoint Maven / Gradle / Ivy

There is a newer version: 3.0.7
Show newest version
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; }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy