Commit Graph

32 Commits

Author SHA1 Message Date
Ryan Butler 33604ba0d1
Merge branch 'master' into rbutler/billing-history 2020-02-28 13:22:14 -06:00
Ryan Butler b1cd87eaa4 Add BillingHistory service and List endpoint 2020-02-28 13:09:24 -06:00
Ben Tranter 40dd0cc93a
Add NewFromToken convenience method to init client (#304)
* Add NewFromToken convenience method to init client

Fixes #296

Adds a new convenience method for creating a new instance of `godo` from
just an API token.

Usage

Right now, it takes quite a few steps to create a `godo` instance:

```go
type TokenSource struct {
	AccessToken string
}

func (t *TokenSource) Token() (*oauth2.Token, error) {
	token := &oauth2.Token{
		AccessToken: t.AccessToken,
	}
	return token, nil
}

func main() {
	tokenSource := &TokenSource{
		AccessToken: pat,
	}

	oauthClient := oauth2.NewClient(context.Background(), tokenSource)
	client := godo.NewClient(oauthClient)
}
```

Now, it takes just a single line:

```go
func main() {
	client := godo.NewFromToken("my-token")
}
```

The intention of this is to make initializing new clients easier. It
also has an additional benefit of not forcing users to have to import
the `golang.org/x/oauth2` dependency just to initialize new `godo`
instances.

* Add NewFromToken convenience method to init client

Fixes #296

Adds a new convenience method for creating a new instance of `godo` from
just an API token.

Usage

Right now, it takes quite a few steps to create a `godo` instance:

```go
type TokenSource struct {
	AccessToken string
}

func (t *TokenSource) Token() (*oauth2.Token, error) {
	token := &oauth2.Token{
		AccessToken: t.AccessToken,
	}
	return token, nil
}

func main() {
	tokenSource := &TokenSource{
		AccessToken: pat,
	}

	oauthClient := oauth2.NewClient(context.Background(), tokenSource)
	client := godo.NewClient(oauthClient)
}
```

Now, it takes just a single line:

```go
func main() {
	client := godo.NewFromToken("my-token")
}
```

The intention of this is to make initializing new clients easier. It
also has an additional benefit of not forcing users to have to import
the `golang.org/x/oauth2` dependency just to initialize new `godo`
instances.

* Remove our own tokenSource type

It turns out you can use an `oauth2.Config` as a token source, so this
removes our own tokenSource type in favour of that one.

Co-authored-by: Zach Gershman <zachgersh@users.noreply.github.com>
2020-02-28 07:58:11 -08:00
Ryan Butler 86ea9fd282 Add invoices - including Get, List, and GetSummary methods 2020-02-11 14:51:29 -06:00
Ryan Butler 6c2309df80 Return balance values from Balance.Get 2019-12-11 15:53:37 -06:00
Steven Normore 6201dd91ab Support unset/nil auto_upgrade field on Kubernetes cluster update. 2019-09-01 16:03:06 -04:00
Steven Normore 175454b6d7 Support unset/nil count field on Kubernetes node pool updates. 2019-09-01 09:11:46 -04:00
Sunny Beatteay 96f3a269f0 storage: add support for spaces cdn 2018-08-22 09:41:21 -04:00
Iheanyi Ekechukwu e6249e5059 Remove support for Go 1.6 (#166)
* Move DoRequest* to godo package with stdlib context

* Use stdlib context package in place of godo context.

* Remove Go 1.6 from TravisCI configuration.

* Use stdlib context in util and tests instead of godo context.

* Add in Go 1.8, 1.9, and 1.10 to TravisCI configuration.

* Put 1.10 in quotes.
2018-05-08 16:24:29 -04:00
Joonas Bergius ac5e3a015f Follow User-Agent header field recommendations 2017-09-22 17:30:06 -06:00
Guus van Weelden 9e24e26f6b use http.MethodX instead of "GET"/"POST"/"DELETE" 2017-07-02 13:55:56 +02:00
akutz 8ed9e9ea6c Portable Go Context Usage
This patch updates the godo package to use a portable Go context -- a
Context that works with Go versions prior to Go 1.7 as well as Go 1.7
and onwards.
2017-04-07 15:32:33 -05:00
Antoine Grondin dc14e4b04d add context.Context to all calls 2017-02-23 14:25:29 -05:00
Erick Guevara a7b77d4c06 adding tests for godo.SetBaseURL() to check BaseURL field and handle parse url errors 2017-01-12 00:50:14 -06:00
Carlos Villela 7c9bf15691 Adds support for creating droplets with monitoring (#117) 2016-12-21 23:05:53 -05:00
Mike Chittenden 82ae4350ef Add Tags attribute to droplet create 2016-11-09 10:57:33 -05:00
Bryan Liles cacf7fa36e Merge pull request #100 from tbalthazar/issue-99
Changing the User Agent doesn't work as expected
2016-06-14 11:25:00 -04:00
Thomas Balthazar cb325e7136 Changing the User Agent doesn't work as expected
Fixes #99
2016-06-14 17:17:36 +02:00
Thomas Balthazar 22de7c48d5 Make sure Client.New() init the different services
Fixes #97
2016-06-14 16:37:22 +02:00
Antoine Grondin 8897364455 remove JSON invalid encoding test
> Go 1.7 adds support for maps using keys with integer types: the
> encoding uses a quoted decimal representation as the JSON key.

in: https://tip.golang.org/doc/go1.7, under encoding/json
2016-06-09 16:38:35 -04:00
bryanl 2db8830c36 create functional option based initializer for Client 2016-04-24 12:54:55 -04:00
bryanl de59235b17 updating documentation for godo 2015-06-01 13:34:27 -04:00
bryanl b4e33ee3ae Don't drop existing query keys
When adding options to a path, don't drop existing keys. This will enable image pagination when there is a type key to work. The bug was trying to addOptions to an existing path with query values. Previously if a path `/path?type=alpha` was passed, key `page=2` would be appeneded, but `type=alpha` would be dropped.
2015-05-29 15:10:21 -07:00
Raphael Simon c4ca5889d2 Add optional API request completion callback to client.
This makes it possible for consumers of the package to debug API calls made to the DO APIs.

Usage:

client.OnRequestCompleted(func(req *http.Request, resp *http.Response) {
	// ... e.g. use httputil.DumpRequest / httputil.DumpResponse
})
2015-05-02 10:29:09 -07:00
Bryce Reitano 107613d25b Omit an empty value for user data to serialize properly. 2015-04-12 18:44:47 -06:00
Bryan Liles 4a70bc6049 Merge pull request #33 from digitalocean/remove-implements-check
Remove testing Implements
2015-03-23 07:37:21 -04:00
bryanl 14a4b3f281 Remove testing Implements
Make adherenence to interface a compile type rather than a test time check.
2015-03-21 15:42:48 -04:00
bryanl f1424cedf5 Add missing error checks
Adds missing error checks to godo. Ensures calls to Client.Do and json decoding are evaluated when neccessary.
2015-03-21 15:21:49 -04:00
Phillip Baker f1ccbcd46f Add image/ssh key structs for explicit type on droplet create.
Closes #22
2015-03-21 14:52:14 -04:00
bryanl 6fc81f4c7a Add all options to droplet create request
Added:

backups, ipv6, private_networking, user_data
2014-10-16 09:36:50 -04:00
bryanl 96accbf5e9 Update to current API spec
* Allow requesting pages in lists by number
* Add tooling to allow examination of page links if they exist
* Add domain management CRUD
2014-09-08 20:36:11 -04:00
bryanl 4b5588d885 Services are interfaces
* Converted services to interfaces to make testing with them
in downstream projects easier to do.
* Removed testify dependency.
2014-09-04 16:22:37 -04:00
Renamed from doapi_test.go (Browse further)