You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/vendor/github.com/packethost/packngo
Jeff Mitchell 28c84845bf
Update vendoring from go mod. (#5566)
6 years ago
..
.drone.yml Update vendoring from go mod. (#5566) 6 years ago
.gitignore Update vendoring from go mod. (#5566) 6 years ago
CHANGELOG.md Vendoring update for go-discover. (#4412) 6 years ago
LICENSE.txt Vendoring update for go-discover. (#4412) 6 years ago
README.md Vendoring update for go-discover. (#4412) 6 years ago
billing_address.go Vendoring update for go-discover. (#4412) 6 years ago
devices.go Vendoring update for go-discover. (#4412) 6 years ago
email.go Vendoring update for go-discover. (#4412) 6 years ago
facilities.go Vendoring update for go-discover. (#4412) 6 years ago
ip.go Vendoring update for go-discover. (#4412) 6 years ago
operatingsystems.go Vendoring update for go-discover. (#4412) 6 years ago
organizations.go Vendoring update for go-discover. (#4412) 6 years ago
packngo.go Vendoring update for go-discover. (#4412) 6 years ago
payment_methods.go Vendoring update for go-discover. (#4412) 6 years ago
plans.go Vendoring update for go-discover. (#4412) 6 years ago
ports.go Vendoring update for go-discover. (#4412) 6 years ago
projects.go Update vendoring from go mod. (#5566) 6 years ago
rate.go Vendoring update for go-discover. (#4412) 6 years ago
spotmarket.go Vendoring update for go-discover. (#4412) 6 years ago
sshkeys.go Vendoring update for go-discover. (#4412) 6 years ago
timestamp.go Vendoring update for go-discover. (#4412) 6 years ago
user.go Vendoring update for go-discover. (#4412) 6 years ago
utils.go Vendoring update for go-discover. (#4412) 6 years ago
virtualnetworks.go Vendoring update for go-discover. (#4412) 6 years ago
volumes.go Vendoring update for go-discover. (#4412) 6 years ago

README.md

packngo

Packet Go Api Client

Installation

go get github.com/packethost/packngo

Usage

To authenticate to the Packet API, you must have your API token exported in env var PACKET_API_TOKEN.

This code snippet initializes Packet API client, and lists your Projects:

package main

import (
	"log"

	"github.com/packethost/packngo"
)

func main() {
	c, err := packngo.NewClient()
	if err != nil {
		log.Fatal(err)
	}

	ps, _, err := c.Projects.List(nil)
	if err != nil {
		log.Fatal(err)
	}
	for _, p := range ps {
		log.Println(p.ID, p.Name)
	}
}

This lib is used by the official terraform-provider-packet.

You can also learn a lot from the *_test.go sources. Almost all out tests touch the Packet API, so you can see how auth, querying and POSTing works. For example devices_test.go.

Acceptance Tests

If you want to run tests against the actual Packet API, you must set envvar PACKET_TEST_ACTUAL_API to non-empty string for the go test. The device tests wait for the device creation, so it's best to run a few in parallel.

To run a particular test, you can do

$ PACKNGO_TEST_ACTUAL_API=1 go test -v -run=TestAccDeviceBasic

If you want to see HTTP requests, set the PACKNGO_DEBUG env var to non-empty string, for example:

$ PACKNGO_DEBUG=1 PACKNGO_TEST_ACTUAL_API=1 go test -v -run=TestAccVolumeUpdate

Committing

Before committing, it's a good idea to run gofmt -w *.go. (gofmt)