Skip to content

Commit

Permalink
virtualdns: allow support for account level resources
Browse files Browse the repository at this point in the history
Updates the virtual DNS API calls to be configured to use the account
level resources now that the user level resources are no more.

Closes #644
  • Loading branch information
jacobbednarz committed Jun 2, 2021
1 parent eabc633 commit cfdb324
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions virtualdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ type VirtualDNSAnalyticsResponse struct {
//
// API reference: https://api.cloudflare.com/#virtual-dns-users--create-a-virtual-dns-cluster
func (api *API) CreateVirtualDNS(ctx context.Context, v *VirtualDNS) (*VirtualDNS, error) {
res, err := api.makeRequestContext(ctx, http.MethodPost, "/user/virtual_dns", v)
uri := fmt.Sprintf("%s/virtual_dns", api.userBaseURL("/user"))
res, err := api.makeRequestContext(ctx, http.MethodPost, uri, v)
if err != nil {
return nil, err
}
Expand All @@ -90,7 +91,7 @@ func (api *API) CreateVirtualDNS(ctx context.Context, v *VirtualDNS) (*VirtualDN
//
// API reference: https://api.cloudflare.com/#virtual-dns-users--get-a-virtual-dns-cluster
func (api *API) VirtualDNS(ctx context.Context, virtualDNSID string) (*VirtualDNS, error) {
uri := fmt.Sprintf("/user/virtual_dns/%s", virtualDNSID)
uri := fmt.Sprintf("%s/virtual_dns/%s", api.userBaseURL("/user"), virtualDNSID)
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, err
Expand All @@ -109,7 +110,8 @@ func (api *API) VirtualDNS(ctx context.Context, virtualDNSID string) (*VirtualDN
//
// API reference: https://api.cloudflare.com/#virtual-dns-users--get-virtual-dns-clusters
func (api *API) ListVirtualDNS(ctx context.Context) ([]*VirtualDNS, error) {
res, err := api.makeRequestContext(ctx, http.MethodGet, "/user/virtual_dns", nil)
uri := fmt.Sprintf("%s/virtual_dns", api.userBaseURL("/user"))
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, err
}
Expand All @@ -127,7 +129,7 @@ func (api *API) ListVirtualDNS(ctx context.Context) ([]*VirtualDNS, error) {
//
// API reference: https://api.cloudflare.com/#virtual-dns-users--modify-a-virtual-dns-cluster
func (api *API) UpdateVirtualDNS(ctx context.Context, virtualDNSID string, vv VirtualDNS) error {
uri := fmt.Sprintf("/user/virtual_dns/%s", virtualDNSID)
uri := fmt.Sprintf("%s/virtual_dns/%s", api.userBaseURL("/user"), virtualDNSID)
res, err := api.makeRequestContext(ctx, http.MethodPut, uri, vv)
if err != nil {
return err
Expand All @@ -147,7 +149,7 @@ func (api *API) UpdateVirtualDNS(ctx context.Context, virtualDNSID string, vv Vi
//
// API reference: https://api.cloudflare.com/#virtual-dns-users--delete-a-virtual-dns-cluster
func (api *API) DeleteVirtualDNS(ctx context.Context, virtualDNSID string) error {
uri := fmt.Sprintf("/user/virtual_dns/%s", virtualDNSID)
uri := fmt.Sprintf("%s/virtual_dns/%s", api.userBaseURL("/user"), virtualDNSID)
res, err := api.makeRequestContext(ctx, http.MethodDelete, uri, nil)
if err != nil {
return err
Expand Down Expand Up @@ -179,7 +181,7 @@ func (o VirtualDNSUserAnalyticsOptions) encode() string {

// VirtualDNSUserAnalytics retrieves analytics report for a specified dimension and time range
func (api *API) VirtualDNSUserAnalytics(ctx context.Context, virtualDNSID string, o VirtualDNSUserAnalyticsOptions) (VirtualDNSAnalytics, error) {
uri := fmt.Sprintf("/user/virtual_dns/%s/dns_analytics/report?%s", virtualDNSID, o.encode())
uri := fmt.Sprintf("%s/virtual_dns/%s/dns_analytics/report?%s", api.userBaseURL("/user"), virtualDNSID, o.encode())
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return VirtualDNSAnalytics{}, err
Expand Down

0 comments on commit cfdb324

Please sign in to comment.