Skip to content

Commit

Permalink
fix: DELETE calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Dec 17, 2024
1 parent b6fbbc6 commit 6af974c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion providers/dns/manageengine/internal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (c *Client) GetAllZoneRecords(ctx context.Context, zoneID int) ([]ZoneRecor
// DeleteZoneRecord deletes a "zone record".
// https://pitstop.manageengine.com/portal/en/kb/articles/manageengine-clouddns-rest-api-documentation#DEL_Delete_10
func (c *Client) DeleteZoneRecord(ctx context.Context, zoneID int, recordID int) error {
endpoint := c.baseURL.JoinPath("dns", "domain", strconv.Itoa(zoneID), "records", "SPF_TXT", strconv.Itoa(recordID))
endpoint := c.baseURL.JoinPath("dns", "domain", strconv.Itoa(zoneID), "records", "SPF_TXT", strconv.Itoa(recordID), "/")

req, err := newRequest(ctx, http.MethodDelete, endpoint, nil)
if err != nil {
Expand Down Expand Up @@ -138,6 +138,8 @@ func (c *Client) do(req *http.Request, result any) error {
return errutils.NewReadResponseError(req, resp.StatusCode, err)
}

println(string(raw)) // TODO debug

err = json.Unmarshal(raw, result)
if err != nil {
return errutils.NewUnmarshalError(req, resp.StatusCode, raw, err)
Expand Down
4 changes: 2 additions & 2 deletions providers/dns/manageengine/internal/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ func TestClient_GetAllZoneRecords_error(t *testing.T) {
}

func TestClient_DeleteZoneRecord(t *testing.T) {
client := setupTest(t, "DELETE /dns/domain/4/records/SPF_TXT/6", http.StatusOK, "zone_record_delete.json")
client := setupTest(t, "DELETE /dns/domain/4/records/SPF_TXT/6/", http.StatusOK, "zone_record_delete.json")

err := client.DeleteZoneRecord(context.Background(), 4, 6)
require.NoError(t, err)
}

func TestClient_DeleteZoneRecord_error(t *testing.T) {
client := setupTest(t, "DELETE /dns/domain/4/records/SPF_TXT/6", http.StatusUnauthorized, "error.json")
client := setupTest(t, "DELETE /dns/domain/4/records/SPF_TXT/6/", http.StatusUnauthorized, "error.json")

err := client.DeleteZoneRecord(context.Background(), 4, 6)
require.Error(t, err)
Expand Down

0 comments on commit 6af974c

Please sign in to comment.