certbot/tools
Mike Fara c8ebcb49bd
Migrate certbot-dns-cloudflare to cloudflare 4.x SDK (#10587)
## Summary

- Migrate `certbot-dns-cloudflare` from the archived `python-cloudflare`
2.x library (`import CloudFlare`) to the actively maintained Cloudflare
Python SDK 4.x (`import cloudflare`)
- Update all API calls to the new SDK surface:
`dns.records.create/list/delete`, `zones.list`, typed response objects
instead of dicts
- Replace `CloudFlare.exceptions.CloudFlareAPIError` with
`cloudflare.APIStatusError` and extract CF error codes from
`response.json()`
- Bump dependency from `cloudflare>=2.19, <2.20` to `cloudflare>=4.0`
- Update oldest pinning from `cloudflare 2.19` to `4.0.0`
- Update all test mocks and assertions accordingly

Fixes #9938

## API Migration

| Operation | Old 2.x | New 4.x |
|---|---|---|
| Import | `import CloudFlare` | `import cloudflare` |
| Client (token) | `CloudFlare.CloudFlare(token=t)` |
`cloudflare.Cloudflare(api_token=t)` |
| Client (key) | `CloudFlare.CloudFlare(email, key)` |
`cloudflare.Cloudflare(api_email=e, api_key=k)` |
| List zones | `cf.zones.get(params={...})` → `list[dict]` |
`cf.zones.list(name=n)` → iterable of Zone objects |
| Create record | `cf.zones.dns_records.post(zone_id, data={...})` |
`cf.dns.records.create(zone_id=id, **data)` |
| List records | `cf.zones.dns_records.get(zone_id, params={...})` |
`cf.dns.records.list(zone_id=id, type=..., ...)` |
| Delete record | `cf.zones.dns_records.delete(zone_id, record_id)` |
`cf.dns.records.delete(dns_record_id=rid, zone_id=zid)` |
| Exceptions | `CloudFlare.exceptions.CloudFlareAPIError` |
`cloudflare.APIStatusError` |

## Test plan

- [x] All 20 existing tests pass with updated mocks
- [x] Credentials INI file format is unchanged — no user-facing config
changes
- [x] Live dry-run renewal tested successfully across 5 domains

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Ember <BeigeBox@users.noreply.github.com>
Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
2026-05-06 09:35:38 -07:00
..
docker update base docker image (#10620) 2026-04-13 12:21:34 -07:00
pinning Migrate certbot-dns-cloudflare to cloudflare 4.x SDK (#10587) 2026-05-06 09:35:38 -07:00
snap Set up dns plugins to use pyproject.toml (#10425) 2025-08-15 09:17:15 -07:00
_release.sh stop running setup.py and switch to python -m build (#10442) 2025-08-22 11:03:00 -07:00
extract_changelog.py Run changelog generation stage on ubuntu-latest, nightly (#10349) 2025-06-20 09:38:34 -07:00
finish_release.py fix finish_release.py (#10503) 2025-12-04 15:15:25 -08:00
notify_mattermost.py Add @ing mattermost notifications to release build successes and failures (#10604) 2026-04-02 14:14:27 -07:00
oldest_constraints.txt Migrate certbot-dns-cloudflare to cloudflare 4.x SDK (#10587) 2026-05-06 09:35:38 -07:00
pip_install.py Drop in uv for pip (#10428) 2025-08-18 13:17:02 -07:00
pipstrap.py Always "pipstrap" when running pip_install.py (#9658) 2023-04-05 16:43:26 -07:00
release.sh switch from gpg2 to gpg (#9985) 2024-08-19 15:24:39 -07:00
requirements.txt Migrate certbot-dns-cloudflare to cloudflare 4.x SDK (#10587) 2026-05-06 09:35:38 -07:00
retry.sh Automatically retry test farm tests (#8325) 2020-09-30 17:05:52 -07:00
sphinx-quickstart.sh update intersphinx mapping (#10074) 2024-12-03 11:16:13 -08:00
venv.py remove python 3.9 support (#10406) 2025-08-12 17:49:02 +00:00