Coder Social home page Coder Social logo

heroku-go's Introduction

Heroku Platform API

GoDoc

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

Usage

$ go mod init myproj
$ cd myproj

Example

package main

import (
	"context"
	"flag"
	"fmt"
	"log"

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

var (
	username = flag.String("username", "", "api username")
	password = flag.String("password", "", "api password")
)

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

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

	h := heroku.NewService(heroku.DefaultClient)
	addons, err := h.AddOnList(context.TODO(), &heroku.ListRange{Field: "name"})
	if err != nil {
		log.Fatal(err)
	}
	for _, addon := range addons {
		fmt.Println(addon.Name)
	}
}
$ go build

heroku-go's People

Contributors

alindeman avatar bernerdschaefer avatar cyberdelia avatar davidji99 avatar dthadi3 avatar lstoll avatar mars avatar mble avatar mikehale avatar ryanbrainard avatar svc-scm avatar talbright avatar vanstee avatar wchrisjohnson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

heroku-go's Issues

Support netrc

Would you welcome a patch that adds a flag to use netrc authentication, instead of the username / password scheme?

latest schema.json invalid

$ script/generate
go: finding github.com/interagent/schematic/cmd/schematic latest
go: finding github.com/interagent/schematic/cmd latest
go: finding github.com/interagent/schematic latest
schematic: duplicate titles detected for identity-provider

Spaces Support

I'm looking to add support for the spaces api. Is this in the works by anyone else?

Built-in retry with exponential back-offs

It would be nice if the client had a built-in retry + back-off algorithm. Not only is this a great feature to add for the general case, it would also be super helpful in the Terraform Heroku provider (see terraform-providers/terraform-provider-heroku/issues/71 for more background.)

I'm happy to work on an implementation, lets discuss first though.

We could look at bringing in https://github.com/cenkalti/backoff or lifting the logic from elsewhere.

WebhookCreateOpts redeclared in this block

Forgive me, for I am new to Go and this may be a trivial issue, but I could not find any resources to help me trouble shoot.

go version go1.8 darwin/amd64

When I run go get github.com/cyberdelia/heroku-go/v3 I receive the following output:

../../cyberdelia/heroku-go/v3/heroku.go:4216:6: WebhookCreateOpts redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4087:6
../../cyberdelia/heroku-go/v3/heroku.go:4228:6: WebhookCreateResult redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4099:6
../../cyberdelia/heroku-go/v3/heroku.go:4245:6: (*Service).WebhookCreate redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4115:6
../../cyberdelia/heroku-go/v3/heroku.go:4250:6: WebhookDeleteResult redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4120:6
../../cyberdelia/heroku-go/v3/heroku.go:4272:6: WebhookInfoResult redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4141:6
../../cyberdelia/heroku-go/v3/heroku.go:4294:6: WebhookListResult redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4162:6
../../cyberdelia/heroku-go/v3/heroku.go:4316:6: WebhookUpdateOpts redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4183:6
../../cyberdelia/heroku-go/v3/heroku.go:4328:6: WebhookUpdateResult redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4195:6
../../cyberdelia/heroku-go/v3/heroku.go:4400:6: WebhookDeliveryListResult redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4385:6
../../cyberdelia/heroku-go/v3/heroku.go:4449:6: WebhookEventListResult redeclared in this block
	previous declaration at ../../cyberdelia/heroku-go/v3/heroku.go:4434:6
../../cyberdelia/heroku-go/v3/heroku.go:4245:6: too many errors```

License for Project

Hello,

Could you add a license for this project or let me know what it is. Is it auto generated code? Trying to use Terraform for a project and this is listed as a dependency.

Ben

Can't use this project as Go module

Hi,

I try to use this project as go module in my project but I don't why he just doesn't work.

I saw that Go module detect him but seems failing to add to go.mod

 GO111MODULE=on go mod tidy
go: finding github.com/mattn/go-runewidth v0.0.4
go: finding github.com/uber-go/atomic v1.3.2
go: finding github.com/olekukonko/tablewriter v0.0.1
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277
go: finding go.uber.org/atomic v1.3.2
go: downloading go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277
go: downloading github.com/olekukonko/tablewriter v0.0.1
go: downloading github.com/uber-go/atomic v1.3.2
go: downloading github.com/stretchr/testify v1.2.2
go: downloading github.com/mattn/go-runewidth v0.0.4
go: downloading go.uber.org/atomic v1.3.2
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: finding github.com/heroku/heroku-go/v3 latest
go: downloading github.com/heroku/heroku-go/v3 v3.0.0-20181110004255-2648bb9b1f27

Once I look into my go.mod I can't see this module...

module mymodule

require (
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/mattn/go-runewidth v0.0.4 // indirect
	github.com/olekukonko/tablewriter v0.0.1
	github.com/pmezard/go-difflib v1.0.0 // indirect
	github.com/stretchr/testify v1.2.2 // indirect
	github.com/uber-go/atomic v1.3.2 // indirect
	go.uber.org/atomic v1.3.2 // indirect
	go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277
)

Does someone try to add this project as go module ?

Generate fails for latest schema

$ script/generate
Error processing schema element:
    {
      "required": [
        "addon"
      ],
      "properties": {
        "addon": {
          "description": "globally unique name of the add-on",
          "readOnly": true,
          "example": "acme-inc-primary-database",
          "type": [
            "string"
          ],
          "pattern": "^[a-zA-Z][A-Za-z0-9_-]+$"
        },
        "addon_service": {
          "description": "unique name of this add-on-service",
          "readOnly": true,
          "example": "heroku-postgresql",
          "type": [
            "string"
          ]
        },
        "app": {
          "description": "unique name of app",
          "example": "example",
          "type": [
            "string"
          ],
          "pattern": "^[a-z][a-z0-9-]{1,28}[a-z0-9]$"
        }
      }
    }

Failed with: unknown type <nil>

Unable to run `make generate`

I'm trying to update the heroku.go with the current latest schema but I'm running into the following error:

cd v5 && ../script/generate
+ : 1
+ getopts hnv: opt
+ API_VERSION=3
+ CLIENT_VERSION=v5
+ SCHEMA_FILE=v5/schema.json
+ GENERATED_FILE=v5/heroku.go
+++ dirname ../script/generate
++ cd ../script/..
++ pwd
+ NEW_DIR=/dev_exclusions/heroku-go
+ cd /dev_exclusions/heroku-go
+ '[' 1 -eq 1 ']'
+ curl -so v5/schema.json https://api.heroku.com/schema -H 'Accept: application/vnd.heroku+json; version=3'
+ go get -u github.com/interagent/schematic/cmd/schematic
go: finding github.com/interagent/schematic/cmd/schematic latest
go: finding github.com/interagent/schematic/cmd latest
go: finding github.com/interagent/schematic latest
+ schematic v5/schema.json
Error processing schema element:
    {
      "description": "certificate provided by this endpoint",
      "properties": {
        "ca_signed?": {
          "readOnly": true,
          "type": [
            "boolean"
          ]
        },
        "cert_domains": {
          "readOnly": true,
          "type": [
            "array"
          ]
        },
        "expires_at": {
          "readOnly": true,
          "format": "date-time",
          "type": [
            "string"
          ]
        },
        "id": {
          "description": "unique identifier of this SSL certificate",
          "readOnly": true,
          "example": "01234567-89ab-cdef-0123-456789abcdef",
          "format": "uuid",
          "type": [
            "string"
          ]
        },
        "issuer": {
          "readOnly": true,
          "type": [
            "string"
          ]
        },
        "self_signed?": {
          "readOnly": true,
          "type": [
            "boolean"
          ]
        },
        "starts_at": {
          "readOnly": true,
          "format": "date-time",
          "type": [
            "string"
          ]
        },
        "subject": {
          "readOnly": true,
          "type": [
            "string"
          ]
        }
      }
    }

Failed with: unknown type <nil>
make: *** [generate] Error 1

This has happened to me in the past and if I recall correctly, the API schema needed to be updated.

@bernerdschaefer @mars Could one of you check if the schema is correct?

Can't get PipelineID from ReviewAppConfig

After upgrading to latest version 5.4.0, I can't get PipelineID from ReviewAppConfig struct:

h := heroku.NewService(heroku.DefaultClient)
reviewAppConfig, err := h.ReviewAppConfigInfo(context.TODO(), "PIPELINE-ID")
if err != nil {
log.Fatal(err)
}
fmt.Println(reviewAppConfig.PipelineID)

This print an empty value.

I have made a call to Heroku API and it seems the pipeline ID is returned as an object but the field PipelineID in the ReviewAppConfig struct was modified here to be a string.

curl -nX GET https://api.heroku.com/pipelines/PIPELINE-ID/review-app-config \
-H "Accept: application/vnd.heroku+json; version=3" 

Response:

{
  ...
  "pipeline": {
    "id": "PIPELINE-ID"
  },
  ...
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.