mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Switch to official Vultr API library (#529)
* vultr: Switched to official API library (closes #528) * vultr: Renamed vultr.VultrApi to vultr.Provider * vendor: Updated govultr
This commit is contained in:
committed by
Craig Peterson
parent
a138b12ec2
commit
44a7ba5711
44
vendor/github.com/vultr/govultr/api.go
generated
vendored
Normal file
44
vendor/github.com/vultr/govultr/api.go
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
package govultr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// APIService is the interface to interact with the API endpoint on the Vultr API
|
||||
// Link: https://www.vultr.com/api/#auth
|
||||
type APIService interface {
|
||||
GetInfo(ctx context.Context) (*API, error)
|
||||
}
|
||||
|
||||
// APIServiceHandler handles interaction with the API methods for the Vultr API
|
||||
type APIServiceHandler struct {
|
||||
client *Client
|
||||
}
|
||||
|
||||
// API represents Vultr API information
|
||||
type API struct {
|
||||
ACL []string `json:"acls"`
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// GetInfo Vultr API auth information
|
||||
func (a *APIServiceHandler) GetInfo(ctx context.Context) (*API, error) {
|
||||
uri := "/v1/auth/info"
|
||||
|
||||
req, err := a.client.NewRequest(ctx, http.MethodGet, uri, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
api := new(API)
|
||||
err = a.client.DoWithContext(ctx, req, api)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return api, nil
|
||||
}
|
Reference in New Issue
Block a user