Categorygithub.com/bgentry/heroku-go
modulepackage
0.0.0-20150810151148-ee4032d686ae
Repository: https://github.com/bgentry/heroku-go.git
Documentation: pkg.go.dev

# README

heroku-go

An API client interface for Heroku for the Go (golang) programming language.

Build Status GoDoc

Background

This package provides a complete interface to all of the Heroku Platform API v3 actions, and is almost entirely auto-generated based on the API's JSON Schema. The exceptions are the files heroku.go, heroku_test.go, and app_test.go, as well as the generator itself. All models are auto-generated by the Ruby script in gen/gen.rb.

The client leverages Go's powerful net/http Client. That means that, out-of-the-box, it has keep-alive support and the ability to handle many concurrent requests from different goroutines.

You should have at least some understanding of Heroku and its Platform API.

Installation

This package is targeted towards Go 1.2 or later, though it may work on earlier versions as well.

Run go get github.com/bgentry/heroku-go to download, build, and install the package.

Getting Started

To use the client, first add it to your Go file's imports list:

import (
  "github.com/bgentry/heroku-go"
)

Then create a Client object and make calls to it:

client := heroku.Client{Username: "[email protected]", Password: "my-api-key"}

// pass nil for options if you don't need to set any optional params
app, err := client.AppCreate(nil)
if err != nil {
  panic(err)
}
fmt.Println("Created", app.Name)

// Output:
// Created dodging-samurai-42

That's it! Here is a more advanced example that also sets some options on the new app:

name := "myapp"
region := "region"

// Optional values need to be provided as pointers. If a field in an option
// struct is nil (not provided), the option is omitted from the API request.
opts := heroku.AppCreateOpts{Name: &name, Region: &region}

// Create an app with options set:
app2, err := client.AppCreate(&opts)
if err != nil {
  // if this is a heroku.Error, it will contain details about the error
  if hkerr, ok := err.(heroku.Error); ok {
    panic(fmt.Sprintf("Error id=%s message=%q", hkerr.Id, hkerr))
  }
}
fmt.Printf("created app2: name=%s region=%s", app2.Name, app2.Region.Name)

// Output:
// created app2: name=myapp region=eu

Optional Parameters

Many of the Heroku Platform API actions have optional parameters. For example, when creating an app, you can either specify a custom name, or allow the API to choose a random haiku name for your app.

Optional parameters in heroku-go are always provided to functions as a pointer to a struct, such as AppCreateOpts for the function AppCreate(). If you do not wish to set any optional parameters, simply provide a nil in place of the options struct, and the options will be omitted from the API request entirely. For any individual options that you don't want to set, simply leave them as nil, and they will be omitted from the API request.

List Ranges & Sorting

Results from the Heroku API are paginated. You can specify a field for sorting and adjust the maximum number of records returned by providing a ListRange to API calls that list objects:

apps, err = client.AppList(&heroku.ListRange{Field: "name", Max: 1000})

Note Field is required when setting any range options.

Documentation

More detailed documentation is available on godoc.

Thank You

A special thanks goes out to Keith Rarick for writing much of the base API client as part of hk. I also want to thank the Heroku API team for making their API available in JSON schema and for the early version of heroics, on which this generator is based.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

An account represents an individual signed up to use the Heroku platform.
An account feature represents a Heroku labs capability that can be enabled or disabled for an account on Heroku.
AccountUpdateOpts holds the optional parameters for AccountUpdate.
Add-ons represent add-ons that have been provisioned for an app.
AddonCreateOpts holds the optional parameters for AddonCreate.
Add-on services represent add-ons that may be provisioned for apps.
An app represents the program that you would like to deploy and run on Heroku.
AppCreateOpts holds the optional parameters for AppCreate.
An app feature represents a Heroku labs capability that can be enabled or disabled for an app on Heroku.
An app transfer represents a two party interaction for transferring ownership of an app.
AppUpdateOpts holds the optional parameters for AppUpdate.
A Client is a Heroku API client.
A collaborator represents an account that has been given access to an app on Heroku.
CollaboratorCreateOpts holds the optional parameters for CollaboratorCreate.
Domains define what web routes should be routed to an app on Heroku.
Dynos encapsulate running processes of an app on Heroku.
DynoCreateOpts holds the optional parameters for DynoCreate.
An Error represents a Heroku API error.
The formation of processes that should be maintained for an app.
No description provided by the author
FormationUpdateOpts holds the optional parameters for FormationUpdate.
Keys represent public SSH keys associated with an account and are used to authorize accounts as they are performing git operations.
No description provided by the author
Log drains provide a way to forward your Heroku logs to an external syslog server for long-term archiving.
A log session is a reference to the http based log stream for an app.
LogSessionCreateOpts holds the optional parameters for LogSessionCreate.
OAuth authorizations represent clients that a Heroku user has authorized to automate, customize or extend their usage of the platform.
OAuthAuthorizationCreateOpts holds the optional parameters for OAuthAuthorizationCreate.
OAuth clients are applications that Heroku users can authorize to automate, customize or extend their usage of the platform.
OAuthClientUpdateOpts holds the optional parameters for OAuthClientUpdate.
OAuth tokens provide access for authorized clients to act on behalf of a Heroku user to automate, customize or extend their usage of the platform.
OAuthTokenCreateClient used in OAuthTokenCreate as the OAuth client secret used to obtain token.
OAuthTokenCreateGrant used in OAuthTokenCreate as the grant used on the underlying authorization.
OAuthTokenCreateRefreshToken used in OAuthTokenCreate as the refresh token for this authorization.
Organizations allow you to manage access to a shared group of applications across your development team.
An organization app encapsulates the organization specific functionality of Heroku apps.
An organization collaborator represents an account that has been given access to an organization app on Heroku.
OrganizationAppCollaboratorCreateOpts holds the optional parameters for OrganizationAppCollaboratorCreate.
OrganizationAppCreateOpts holds the optional parameters for OrganizationAppCreate.
An organization member is an individual with access to an organization.
OrganizationUpdateOpts holds the optional parameters for OrganizationUpdate.
Plans represent different configurations of add-ons that may be added to apps.
Rate Limit represents the number of request tokens each account holds.
A region represents a geographic location in which your application may run.
A release represents a combination of code, config vars and add-ons for an app on Heroku.
ReleaseCreateOpts holds the optional parameters for ReleaseCreate.
A slug is a snapshot of your application code that is ready to run on the platform.
SlugCreateOpts holds the optional parameters for SlugCreate.
SSL Endpoint is a public address serving custom SSL cert for HTTPS traffic to a Heroku app.
SSLEndpointCreateOpts holds the optional parameters for SSLEndpointCreate.
SSLEndpointUpdateOpts holds the optional parameters for SSLEndpointUpdate.
Stacks are the different application execution environments available in the Heroku platform.