Skip to content

droplets: support usage-based backup policies#997

Open
theredspoon wants to merge 1 commit intodigitalocean:mainfrom
theredspoon:droplets/usage-based-backup-policy
Open

droplets: support usage-based backup policies#997
theredspoon wants to merge 1 commit intodigitalocean:mainfrom
theredspoon:droplets/usage-based-backup-policy

Conversation

@theredspoon
Copy link
Copy Markdown

Summary

  • add window_length_hours and retention_period_days to DropletBackupPolicyRequest
  • include those fields in Droplet create, multi-create, and backup-policy action payloads when set
  • omit empty weekday from backup-policy action payloads, which allows usage-based policies such as intra_daily_4h

Context

DigitalOcean supports newer usage-based Droplet backup policies such as:

{
  "plan": "intra_daily_4h",
  "hour": 0,
  "window_length_hours": 4,
  "retention_period_days": 7
}

godo can already read these fields through DropletBackupPolicyConfig, but DropletBackupPolicyRequest and the Droplet action helpers could only send plan, weekday, and hour.

This is needed by the Terraform/OpenTofu provider so it can model usage-based backup policies without out-of-band API calls. Related provider issue: digitalocean/terraform-provider-digitalocean#1525.

Tests

go test -run 'TestDroplets_CreateWithUsageBasedBackupPolicy|TestDroplets_CreateMultipleWithUsageBasedBackupPolicy' ./...
go test .
go test ./...

@theredspoon theredspoon force-pushed the droplets/usage-based-backup-policy branch from aa7ab4f to bcd2404 Compare April 22, 2026 23:54
@theredspoon
Copy link
Copy Markdown
Author

Small status update from downstream provider usage:

  • This SDK change is the write-path prerequisite for Support usage-based Droplet backup policies terraform-provider-digitalocean#1525.
  • I verified the raw Droplet action API accepts a usage-based backup policy when retention_period_days and window_length_hours are sent with plan: "intra_daily_4h".
  • The policy reads back through doctl compute droplet backup-policies get as intra_daily_4h, hour 0, window 4, retention 7.
  • I rebased this branch on current digitalocean/godo:main and go test -mod=mod . passes locally on the rebased branch.

I also tried the documented go test -mod=vendor . command from CONTRIBUTING.md, but the current digitalocean/godo repo does not include a populated vendor/ tree or vendor/modules.txt, so vendor mode exits before running tests.

Happy to adjust the SDK shape if maintainers prefer a different API surface. I kept this PR SDK-only so the provider can update godo through normal module tooling after release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant