1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Update digitalocean module (#622)

Related #619
This commit is contained in:
Juho Teperi
2020-02-14 13:40:14 +02:00
committed by GitHub
parent 0f07d91f54
commit 737c8b5616
36 changed files with 695 additions and 84 deletions

View File

@@ -17,7 +17,7 @@ import (
)
const (
libraryVersion = "1.17.0"
libraryVersion = "1.30.0"
defaultBaseURL = "https://api.digitalocean.com/"
userAgent = "godo/" + libraryVersion
mediaType = "application/json"
@@ -45,6 +45,7 @@ type Client struct {
// Services used for communicating with the API
Account AccountService
Actions ActionsService
Balance BalanceService
CDNs CDNService
Domains DomainsService
Droplets DropletsService
@@ -65,6 +66,7 @@ type Client struct {
Firewalls FirewallsService
Projects ProjectsService
Kubernetes KubernetesService
Registry RegistryService
Databases DatabasesService
VPCs VPCsService
@@ -93,6 +95,9 @@ type Response struct {
// request body and not the header.
Links *Links
// Meta describes generic information about the response.
Meta *Meta
// Monitoring URI
Monitor string
@@ -161,6 +166,7 @@ func NewClient(httpClient *http.Client) *Client {
c := &Client{client: httpClient, BaseURL: baseURL, UserAgent: userAgent}
c.Account = &AccountServiceOp{client: c}
c.Actions = &ActionsServiceOp{client: c}
c.Balance = &BalanceServiceOp{client: c}
c.CDNs = &CDNServiceOp{client: c}
c.Certificates = &CertificatesServiceOp{client: c}
c.Domains = &DomainsServiceOp{client: c}
@@ -181,6 +187,7 @@ func NewClient(httpClient *http.Client) *Client {
c.StorageActions = &StorageActionsServiceOp{client: c}
c.Tags = &TagsServiceOp{client: c}
c.Kubernetes = &KubernetesServiceOp{client: c}
c.Registry = &RegistryServiceOp{client: c}
c.Databases = &DatabasesServiceOp{client: c}
c.VPCs = &VPCsServiceOp{client: c}
@@ -227,13 +234,11 @@ func SetUserAgent(ua string) ClientOpt {
// BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the
// value pointed to by body is JSON encoded and included in as the request body.
func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error) {
rel, err := url.Parse(urlStr)
u, err := c.BaseURL.Parse(urlStr)
if err != nil {
return nil, err
}
u := c.BaseURL.ResolveReference(rel)
buf := new(bytes.Buffer)
if body != nil {
err = json.NewEncoder(buf).Encode(body)