|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.heroku.api.HerokuAPI
public class HerokuAPI
A convenience class for making HTTP requests to the Heroku API for a given user. An underlying Connection
is created
for each instance of HerokuAPI. To make HTTP requests to the Heroku API in multi-user or systems that have resource
constraints (e.g. a pool of Connection
objects are required), Connection
should be used
directly.
HerokuAPI heroku = new HerokuAPI("apiKey");
App app = heroku.createApp();
heroku.scaleProcess(app.getName(), "web", 1)
RuntimeException
will be thrown for any request failures.
Field Summary | |
---|---|
protected String |
apiKey
|
protected Connection |
connection
|
Constructor Summary | |
---|---|
HerokuAPI(Connection connection,
String apiKey)
|
|
HerokuAPI(String apiKey)
Constructs a HerokuAPI with a Connection based on the first ConnectionProvider
found on the classpath. |
Method Summary | |
---|---|
AddonChange |
addAddon(String appName,
String addonName)
Add an addon to the app. |
void |
addCollaborator(String appName,
String collaborator)
Add a collaborator to an app. |
void |
addConfig(String appName,
Map<String,String> config)
Add environment variables to an app. |
void |
addKey(String sshKey)
Add an ssh key to the current user's account. |
boolean |
appExists(String name)
Checks if an app with the given name exists on Heroku. |
App |
cloneApp(String templateAppName)
Clone an existing app that has previously been designated as a template into the authenticated user's account with a randomly generated name. |
App |
cloneApp(String templateAppName,
App targetApp)
Clone an existing app that has previously been designated as a template into the authenticated user's account with details specified in the target app. |
App |
createApp()
Create a new app on the Heroku.Stack.Cedar stack. |
App |
createApp(App app)
Create a new app using App to specify parameters. |
void |
destroyApp(String appName)
Delete an app. |
App |
getApp(String name)
Get information about a specific app. |
Connection |
getConnection()
|
LogStreamResponse |
getLogs(Log.LogRequestBuilder logRequest)
Get logs for an app by specifying additional parameters. |
LogStreamResponse |
getLogs(String appName)
Get logs for an app. |
Release |
getReleaseInfo(String appName,
String releaseName)
Information about a specific release. |
User |
getUserInfo()
Information for the current user. |
boolean |
isAppNameAvailable(String name)
Checks if the given app name is available on Heroku. |
boolean |
isMaintenanceModeEnabled(String appName)
Checks if maintenance mode is enabled for the given app |
List<Addon> |
listAllAddons()
Get a list of all addons available. |
List<Addon> |
listAppAddons(String appName)
List the addons already added to an app. |
List<App> |
listApps()
List all apps for the current user's account. |
List<StackInfo> |
listAppStacks(String appName)
Gets a list of stacks available. |
List<Collaborator> |
listCollaborators(String appName)
Get a list of collaborators that are allowed access to an app. |
Map<String,String> |
listConfig(String appName)
List all the environment variables for an app. |
List<Key> |
listKeys()
Get a list of keys associated with the current user's account. |
List<Proc> |
listProcesses(String appName)
List of processes running for an app. |
List<Release> |
listReleases(String appName)
List of releases for an app. |
String |
migrateStack(String appName,
Heroku.Stack migrateTo)
Migrates an app from its current stack to the specified stack. |
static String |
obtainApiKey(String username,
String password)
Logs into the Heroku API and retrieves an API key for a given username and password using HTTP Basic Authentication. |
AddonChange |
removeAddon(String appName,
String addonName)
Remove an addon from an app. |
void |
removeCollaborator(String appName,
String collaborator)
Remove a collaborator from an app. |
Map<String,String> |
removeConfig(String appName,
String configVarName)
Remove an environment variable from an app. |
void |
removeKey(String sshKey)
Delete an ssh key from the current user's account. |
String |
renameApp(String appName,
String newName)
Rename an existing app. |
void |
restart(String appName)
Restart an app. |
void |
restartProcessByName(String appName,
String procName)
Restart a named process. |
void |
restartProcessByType(String appName,
String type)
Restart a process for an app. |
String |
rollback(String appName,
String releaseName)
Rollback an app to a specific release. |
void |
run(String appName,
String command)
Run a one-off process on a Heroku dyno. |
RunResponse |
runAttached(String appName,
String command)
Run a one-off process on a Heroku dyno in an attached state. |
void |
scaleProcess(String appName,
String processType,
int quantity)
Change the number of processes running for a given process type. |
void |
setMaintenanceMode(String appName,
boolean enable)
Sets maintenance mode for the given app |
void |
transferApp(String appName,
String to)
Transfer the ownership of an application to another user. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Connection connection
protected final String apiKey
Constructor Detail |
---|
public HerokuAPI(String apiKey)
Connection
based on the first ConnectionProvider
found on the classpath.
apiKey
- User's API key found at https://api.heroku.com/accountpublic HerokuAPI(Connection connection, String apiKey)
connection
- apiKey
- User's API key found at https://api.heroku.com/accountMethod Detail |
---|
public static String obtainApiKey(String username, String password)
username
- Heroku username.password
- Heroku password.
public Connection getConnection()
public User getUserInfo()
public void addKey(String sshKey)
sshKey
- Public key value. e.g. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCz29znMi/UJX/nvkRSO5FFugKhU9DkkI53E0vXUnP8zeLFxMgyUqmXryPVjWtGzz2LRWqjm14SbqHAmM44pGHVfBIp6wCKBWSUYGv/FxOulwYgtWzz4moxWLZrFyWWgJAnehcVUifHNgzKwT2ovWm2ns52681Z8yFK3K8/uLStDjLIaPePEOaxaTvgIxZNsfyEoXoHcyTPwdR1GtQuDTuDYqYmjmPCoKybYnXrTQ1QFuQxDneBkswQYSl0H2aLf3uBK4F01hr+azXQuSe39eSV4I/TqzmNJlanpILT9Jz3/J1i4r6brpF3AxLnFnb9ufIbzQAIa/VZIulfrZkcBsUl [email protected]public void removeKey(String sshKey)
sshKey
- The comment in the public key. See listKeys()
to get a list of keys that can be removed.public List<Key> listKeys()
public List<App> listApps()
public App getApp(String name)
name
- The name of the app. See listApps()
to get a list of apps and their names.
public boolean appExists(String name)
getApp(String)
to check user access.
name
- name of the app
public boolean isAppNameAvailable(String name)
name
- name of the app
public App createApp()
Heroku.Stack.Cedar
stack. For more information about the Cedar stack, please see
the Dev Center.
public App createApp(App app)
App
to specify parameters. App
has convenience methods for specifying
parameters to send as part of the request. Typically, these will be the name of the app and the requested stack. e.g.
heroku.createApp(new App().on(Heroku.Stack.Cedar).named("new-app")
app
- See App
public App cloneApp(String templateAppName)
Heroku.Stack.Cedar
stack.
templateAppName
- Name of the template app to clone.
public App cloneApp(String templateAppName, App targetApp)
Heroku.Stack.Cedar
stack.
templateAppName
- Name of the template app to clone.targetApp
- Details about the target app.
public String renameApp(String appName, String newName)
appName
- Existing app name. See listApps()
for names that can be used.newName
- New name to give the existing app.
public void destroyApp(String appName)
appName
- public AddonChange addAddon(String appName, String addonName)
appName
- App name. See listApps()
for a list of apps that can be used.addonName
- Addon name. See listAllAddons()
to get a list of addons that can be used.
public List<Addon> listAllAddons()
public List<Addon> listAppAddons(String appName)
appName
-
public AddonChange removeAddon(String appName, String addonName)
appName
- App name. See listApps()
for a list of apps that can be used.addonName
- Addon name. See listAppAddons(java.lang.String)
for a list of addons that can be used.
public void scaleProcess(String appName, String processType, int quantity)
appName
- App name. See listApps()
for a list of apps that can be used.processType
- Process name. See listProcesses(java.lang.String)
for a list of processes that can be used.quantity
- The number to scale the process to.public List<Proc> listProcesses(String appName)
appName
- App name. See listApps()
for a list of apps that can be used.
public List<Release> listReleases(String appName)
appName
- App name. See listApps()
for a list of apps that can be used.
public String rollback(String appName, String releaseName)
appName
- App name. See listApps()
for a list of apps that can be used.releaseName
- Release name. See listReleases(java.lang.String)
for a list of the app's releases.
public Release getReleaseInfo(String appName, String releaseName)
appName
- App name. See listApps()
for a list of apps that can be used.releaseName
- Release name. See listReleases(java.lang.String)
for a list of the app's releases.
public List<Collaborator> listCollaborators(String appName)
appName
- App name. See listApps()
for a list of apps that can be used.
public void addCollaborator(String appName, String collaborator)
appName
- App name. See listApps()
for a list of apps that can be used.collaborator
- Username of the collaborator to add. This is usually in the form of "[email protected]".public void removeCollaborator(String appName, String collaborator)
appName
- App name. See listApps()
for a list of apps that can be used.collaborator
- See listCollaborators(java.lang.String)
for collaborators that can be removed from the app.public void addConfig(String appName, Map<String,String> config)
appName
- App name. See listApps()
for a list of apps that can be used.config
- Key/Value pairs of environment variables.public Map<String,String> listConfig(String appName)
appName
- App name. See listApps()
for a list of apps that can be used.
public Map<String,String> removeConfig(String appName, String configVarName)
appName
- App name. See listApps()
for a list of apps that can be used.configVarName
- Name of the environment variable. See listConfig(java.lang.String)
for variables that can be removed
public void transferApp(String appName, String to)
appName
- App name. See listApps()
for a list of apps that can be used.to
- Username of the person to transfer the app to. This is usually in the form of "[email protected]".public LogStreamResponse getLogs(String appName)
appName
- App name. See listApps()
for a list of apps that can be used.
public LogStreamResponse getLogs(Log.LogRequestBuilder logRequest)
logRequest
- See LogRequestBuilder
public void run(String appName, String command)
appName
- App name. See listApps()
for a list of apps that can be used.command
- Bash command to run inside a dyno. See One-off processes.public RunResponse runAttached(String appName, String command)
RunResponse.attach()
for more information on running an attached process.
appName
- App name. See listApps()
for a list of apps that can be used.command
- Bash command to run inside a dyno. See One-off processes.
public void restart(String appName)
appName
- See listApps()
for a list of apps that can be used.public void restartProcessByType(String appName, String type)
appName
- See listApps()
for a list of apps that can be used.type
- The type of process to restart. e.g. web, worker, etc...public void restartProcessByName(String appName, String procName)
appName
- See listApps()
for a list of apps that can be used.procName
- Name of process to restart.public String migrateStack(String appName, Heroku.Stack migrateTo)
com.heroku.api.Heroku.Stack.Bamboo187
to com.heroku.api.Heroku.Stack.Bamboo192
, but not to com.heroku.api.Heroku.Stack.Cedar
.
appName
- See listApps()
for a list of apps that can be used.migrateTo
- Stack to migrate the app to.
public List<StackInfo> listAppStacks(String appName)
appName
- See listApps()
for a list of apps that can be used.
public boolean isMaintenanceModeEnabled(String appName)
appName
- See listApps()
for a list of apps that can be used.
public void setMaintenanceMode(String appName, boolean enable)
appName
- See listApps()
for a list of apps that can be used.enable
- true to enable; false to disable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |