cloudflare / cloudflare/cloudflare-python

Add typed methods for Load Balancing Analytics Events and Pool Health endpoints

未關閉
#2,693 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
kind: enhancement
主要語言
Python
星號
506
分支
148
平均合併
3 小時 15 分鐘
30 天內合併 PR
1

描述

## Feature Request

The Python SDK is missing typed methods for two Load Balancing endpoints that are documented in the Cloudflare REST API:

### 1. Load Balancing Analytics Events

**REST endpoint:** `GET /accounts/{account_id}/load_balancing_analytics/events`

Returns per-origin health state change events with timestamps, pool health status, failure reasons, and response codes. This is critical for monitoring when individual origins go unhealthy.

**Current workaround:**
```python
resp = client.with_raw_response.get(
f"/accounts/{account_id}/load_balancing_analytics/events",
cast_to=object,
options={"params": {"per_page": 200, "page": 1, "since": "...", "until": "..."}}
)
data = resp.json()
```

**Desired:**
```python
events = client.load_balancers.analytics.events.list(
account_id=account_id,
since="2026-03-18T00:00:00Z",
until="2026-03-18T23:59:59Z",
)
```

### 2. Pool Health Details

**REST endpoint:** `GET /accounts/{account_id}/load_balancers/pools/{pool_id}/health`

Returns per-PoP, per-origin health status including response codes, RTT, and failure reasons. Useful for diagnosing which specific origins are failing and from which regions.

**Current workaround:**
```python
resp = client.with_raw_response.get(
f"/accounts/{account_id}/load_balancers/pools/{pool_id}/health",
cast_to=object,
)
data = resp.json()
```

**Desired:**
```python
health = client.load_balancers.pools.health.get(
pool_id=pool_id,
account_id=account_id,
)
```

### Use Case

We built an origin health monitor that detects when individual load balancer origins are unhealthy while the pool remains healthy (silent degradation / lost redundancy). Both endpoints are essential for this use case and are documented in the Cloudflare API docs, but require falling back to raw HTTP via `with_raw_response.get()`.

### References

- [Pool Health API docs](https://developers.cloudflare.com/api/resources/load_balancers/subresources/pools/subresources/health/methods/get/)
- [Load Balancing Analytics](https://developers.cloudflare.com/load-balancing/reference/load-balancing-analytics/)

貢獻指南

開啟貢獻指南

研究方向

從已記錄的 REST 端點以及用戶端進入點 `load_balancers.analytics.events.list` 和 `load_balancers.pools.health.get` 開始,然後比較附近的型別化 SDK 資源。完成的標準是兩個端點都可透過型別化方法使用,並公開文件中記錄的事件欄位和逐 origin 的健康狀態欄位,而不需要使用 `with_raw_response.get()`。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
api, backend-api-design
Issue 類型
功能
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
58/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。