Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.16', '1.17' ]
go: [ '1.24' ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ SRC = $(shell find . -type f -name '*.go' -not -path "*vendor/*")
default: build

build: checks
cd v5 && go install .
cd v6 && go install .

generate:
cd v5 && ../script/generate
cd v6 && ../script/generate

checks: fmt-check

Expand Down
64 changes: 58 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

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

Please note: [major version changes](#major-version-changes).

## Usage

$ go mod init myproj
$ go mod get -u github.com/heroku/heroku-go/v6
$ cd myproj

## Example
Expand All @@ -20,20 +23,18 @@ import (
"fmt"
"log"

heroku "github.com/heroku/heroku-go/v5"
heroku "github.com/heroku/heroku-go/v6"
)

var (
username = flag.String("username", "", "api username")
password = flag.String("password", "", "api password")
apiKey = flag.String("api-key", "", "Heroku API key")
)

func main() {
log.SetFlags(0)
flag.Parse()

heroku.DefaultTransport.Username = *username
heroku.DefaultTransport.Password = *password
heroku.DefaultTransport.BearerToken = *apiKey

h := heroku.NewService(heroku.DefaultClient)
addons, err := h.AddOnList(context.TODO(), &heroku.ListRange{Field: "name"})
Expand All @@ -46,4 +47,55 @@ func main() {
}
```

$ go build
## Major Version Changes

### `v5``v6`

The Formation type's `Size` string property moved to `DynoSize` struct property, which can identify a dyno size by ID or Name.

In `v5`:

```go
import (
heroku "github.com/heroku/heroku-go/v5"
)

opts := heroku.FormationUpdateOpts{}
newSize := "standard-1x"
opts.Size = &newSize
```

…becomes in `v6`

```go
import (
heroku "github.com/heroku/heroku-go/v6"
)

opts := heroku.FormationUpdateOpts{}
newSize := "standard-1x"
opts.DynoSize = &struct {
ID *string `json:"id,omitempty" url:"id,omitempty,key"` // unique identifier of the dyno size
Name *string `json:"name,omitempty" url:"name,omitempty,key"` // name of the dyno size
}{
Name: &newSize,
}
```

## Development

### Update Client for Schema

This client is auto-generated from the JSON Schema published by the Heroku Platform API.

To fetch the current `schema.json` and generate an updated client:
```console
make generate
```

To use the existing `schema.json` to generate an updated client:
```console
UPDATE_SCHEMA=0 make generate
```

See [`script/generate`](script/generate) for more details.
7 changes: 5 additions & 2 deletions script/generate
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ while getopts "hnv:" opt; do
done

API_VERSION="3"
CLIENT_VERSION="v5"
CLIENT_VERSION="v6"
SCHEMA_FILE="$CLIENT_VERSION/schema.json"
GENERATED_FILE="$CLIENT_VERSION/heroku.go"

Expand All @@ -39,12 +39,15 @@ if [ $UPDATE_SCHEMA -eq 1 ]; then
-H "Accept: application/vnd.heroku+json; version=$API_VERSION"
fi

go install github.com/interagent/schematic/cmd/schematic@7f954c20daa584c8b9a5c13bce4973dbd2539482
go install github.com/interagent/schematic/cmd/schematic@latest

schematic "$SCHEMA_FILE" > "$GENERATED_FILE"

sed -E -i '' \
"s/^([[:space:]]*Version[[:space:]]*=[[:space:]]*)\"\"\$/\1\"${CLIENT_VERSION}\"/" \
"$GENERATED_FILE"
sed -E -i '' \
"s/^package heroku/package ${CLIENT_VERSION}/g" \
"$GENERATED_FILE"

gofmt -w "$GENERATED_FILE"
10 changes: 3 additions & 7 deletions v5/heroku.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
// To be able to interact with this API, you have to
// create a new service:
//
// s := heroku.NewService(nil)
// s := heroku.NewService(nil)
//
// The Service struct has all the methods you need
// to interact with heroku API.
//
package v5

import (
Expand Down Expand Up @@ -2142,7 +2141,6 @@ type EnterpriseAccountDailyUsageInfoResult []EnterpriseAccountDailyUsage
// from the [enterprise account
// list](https://devcenter.heroku.com/articles/platform-api-reference#ent
// erprise-account-list).
//
func (s *Service) EnterpriseAccountDailyUsageInfo(ctx context.Context, enterpriseAccountID string, o EnterpriseAccountDailyUsageInfoOpts, lr *ListRange) (EnterpriseAccountDailyUsageInfoResult, error) {
var enterpriseAccountDailyUsage EnterpriseAccountDailyUsageInfoResult
return enterpriseAccountDailyUsage, s.Get(ctx, &enterpriseAccountDailyUsage, fmt.Sprintf("/enterprise-accounts/%v/usage/daily", enterpriseAccountID), o, lr)
Expand Down Expand Up @@ -2255,7 +2253,6 @@ type EnterpriseAccountMonthlyUsageInfoResult []EnterpriseAccountMonthlyUsage
// [enterprise account
// list](https://devcenter.heroku.com/articles/platform-api-reference#ent
// erprise-account-list).
//
func (s *Service) EnterpriseAccountMonthlyUsageInfo(ctx context.Context, enterpriseAccountID string, o EnterpriseAccountMonthlyUsageInfoOpts, lr *ListRange) (EnterpriseAccountMonthlyUsageInfoResult, error) {
var enterpriseAccountMonthlyUsage EnterpriseAccountMonthlyUsageInfoResult
return enterpriseAccountMonthlyUsage, s.Get(ctx, &enterpriseAccountMonthlyUsage, fmt.Sprintf("/enterprise-accounts/%v/usage/monthly", enterpriseAccountID), o, lr)
Expand Down Expand Up @@ -2965,7 +2962,8 @@ func (s *Service) PasswordResetCompleteResetPassword(ctx context.Context, passwo
}

// [Peering](https://devcenter.heroku.com/articles/private-space-peering)
// provides a way to peer your Private Space VPC to another AWS VPC.
//
// provides a way to peer your Private Space VPC to another AWS VPC.
type Peering struct {
AwsAccountID string `json:"aws_account_id" url:"aws_account_id,key"` // The AWS account ID of your Private Space.
AwsRegion string `json:"aws_region" url:"aws_region,key"` // The AWS region of the peer connection.
Expand Down Expand Up @@ -4481,7 +4479,6 @@ type TeamDailyUsageInfoResult []TeamDailyUsage
// YYYY-MM-DD. The team identifier can be found from the [team list
// endpoint](https://devcenter.heroku.com/articles/platform-api-reference
// #team-list).
//
func (s *Service) TeamDailyUsageInfo(ctx context.Context, teamID string, o TeamDailyUsageInfoOpts, lr *ListRange) (TeamDailyUsageInfoResult, error) {
var teamDailyUsage TeamDailyUsageInfoResult
return teamDailyUsage, s.Get(ctx, &teamDailyUsage, fmt.Sprintf("/teams/%v/usage/daily", teamID), o, lr)
Expand Down Expand Up @@ -4788,7 +4785,6 @@ type TeamMonthlyUsageInfoResult []TeamMonthlyUsage
// The team identifier can be found from the [team list
// endpoint](https://devcenter.heroku.com/articles/platform-api-reference
// #team-list).
//
func (s *Service) TeamMonthlyUsageInfo(ctx context.Context, teamID string, o TeamMonthlyUsageInfoOpts, lr *ListRange) (TeamMonthlyUsageInfoResult, error) {
var teamMonthlyUsage TeamMonthlyUsageInfoResult
return teamMonthlyUsage, s.Get(ctx, &teamMonthlyUsage, fmt.Sprintf("/teams/%v/usage/monthly", teamID), o, lr)
Expand Down
11 changes: 11 additions & 0 deletions v6/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/heroku/heroku-go/v6

go 1.24

require (
github.com/cenkalti/backoff v2.1.1+incompatible
github.com/google/go-querystring v1.0.0
github.com/pborman/uuid v1.2.0
)

require github.com/google/uuid v1.0.0 // indirect
8 changes: 8 additions & 0 deletions v6/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY=
github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
Loading