public class HerokuAPI extends Object
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.Modifier and Type | Field and Description |
---|---|
protected String |
apiKey |
protected Connection |
connection |
Constructor and Description |
---|
HerokuAPI(Connection connection,
String apiKey) |
HerokuAPI(String apiKey)
Constructs a HerokuAPI with a
Connection based on the first ConnectionProvider
found on the classpath. |
Modifier and Type | Method and Description |
---|---|
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 |
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 |
createApp()
Create a new app on the {Heroku.Stack.Cedar14} stack.
|
App |
createApp(App app)
Create a new app using
App to specify parameters. |
Build |
createBuild(String appName,
Build build)
Creates a build
|
Slug |
createSlug(String appName,
Map<String,String> processTypes)
Gets the slug info for an existing slug
|
Source |
createSource()
Creates a source
|
void |
destroyApp(String appName)
Delete an app.
|
App |
getApp(String name)
Get information about a specific app.
|
Build |
getBuildInfo(String appName,
String buildId)
Gets the info for a running build
|
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.
|
LogStreamResponse |
getLogs(String appName,
Boolean tail)
Get logs for an app.
|
Release |
getReleaseInfo(String appName,
String releaseName)
Information about a specific release.
|
Slug |
getSlugInfo(String appName,
String slugId)
Gets the slug info for an existing slug
|
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.
|
Range<App> |
listApps()
List all apps for the current user's account.
|
Range<App> |
listApps(String range)
List all apps for the current user's account.
|
List<StackInfo> |
listAppStacks()
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.
|
Range<Dyno> |
listDynos(String appName)
List app dynos for an app
|
List<Formation> |
listFormation(String appName)
Lists the formation info for an app
|
List<Key> |
listKeys()
Get a list of keys associated with the current user's account.
|
List<Release> |
listReleases(String appName)
List of releases for an app.
|
AddonChange |
removeAddon(String appName,
String addonName)
Remove an addon from an app.
|
void |
removeCollaborator(String appName,
String collaborator)
Remove a collaborator 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 |
restartDyno(String appName,
String dynoId)
Restarts a single dyno
|
void |
restartDynos(String appName)
Restarts all dynos for an app
|
Release |
rollback(String appName,
String releaseUuid)
Rollback an app to a specific release.
|
Formation |
scale(String appName,
String processType,
int quantity)
Scales a 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.
|
void |
updateConfig(String appName,
Map<String,String> config)
Update environment variables to an app.
|
protected final Connection connection
protected final String apiKey
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
- the connection to Heroku APIapiKey
- User's API key found at https://api.heroku.com/accountpublic 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 Range<App> listApps()
public Range<App> listApps(String range)
range
- The range of apps provided by Range.getNextRange()
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 apppublic boolean isAppNameAvailable(String name)
name
- name of the apppublic App createApp()
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 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
- the app namepublic 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
- new of the apppublic 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 List<Release> listReleases(String appName)
appName
- App name. See listApps()
for a list of apps that can be used.public Release rollback(String appName, String releaseUuid)
appName
- App name. See listApps()
for a list of apps that can be used.releaseUuid
- Release UUID. 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 updateConfig(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 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(String appName, Boolean tail)
appName
- App name. See listApps()
for a list of apps that can be used.public LogStreamResponse getLogs(Log.LogRequestBuilder logRequest)
logRequest
- See {LogRequestBuilder}public List<StackInfo> listAppStacks()
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 disablepublic Slug createSlug(String appName, Map<String,String> processTypes)
appName
- See listApps()
for a list of apps that can be used.processTypes
- hash mapping process type names to their respective commandpublic Slug getSlugInfo(String appName, String slugId)
appName
- See listApps()
for a list of apps that can be used.slugId
- the unique identifier of the slugpublic Source createSource()
public Build createBuild(String appName, Build build)
appName
- See listApps()
for a list of apps that can be used.build
- the build informationpublic Build getBuildInfo(String appName, String buildId)
appName
- See listApps()
for a list of apps that can be used.buildId
- the unique identifier of the buildpublic Range<Dyno> listDynos(String appName)
appName
- See listApps()
for a list of apps that can be used.public void restartDyno(String appName, String dynoId)
appName
- See listApps()
for a list of apps that can be used.dynoId
- the unique identifier of the dyno to restartpublic void restartDynos(String appName)
appName
- See listApps()
for a list of apps that can be used.public Formation scale(String appName, String processType, int quantity)
appName
- See listApps()
for a list of apps that can be used.processType
- type of process to maintainquantity
- number of processes to maintainpublic List<Formation> listFormation(String appName)
appName
- See listApps()
for a list of apps that can be used.Copyright © 2017. All rights reserved.