feat(proxy): sync proxy_referrals.py from deploy; expose via API
The deploy at /srv/pry/ had a thin proxy_referrals.py with 5 curated
proxy provider affiliate entries (Bright Data, Oxylabs, Smartproxy,
IPRoyal, Webshare). The repo was missing this file, so deploy and repo
were out of sync.
Changes:
- Add proxy_referrals.py (MIT) with the 5-provider curated catalog
- proxy_manager.py: import PROVIDER_REFERRALS, add 4 helper methods:
get_proxy_referral(tag)
get_proxy_referral_url(tag)
list_proxy_referrals()
get_proxy_referral_summary() - per-tier breakdown
- api.py: expose 2 new endpoints
GET /v1/proxy/referrals - full catalog + summary
GET /v1/proxy/referrals/{tag} - single provider
- 12/12 existing proxy_manager tests still pass
- Total routes: 195 -> 197
This commit is contained in:
parent
465ff0bd55
commit
239543d695
3 changed files with 131 additions and 0 deletions
34
api.py
34
api.py
|
|
@ -4132,6 +4132,40 @@ async def proxy_signup(provider: str = Body(...)) -> dict[str, Any]:
|
|||
url = pm.get_signup_link(provider)
|
||||
return {"success": True, "data": {"signup_url": url, "provider": provider}}
|
||||
|
||||
@app.get("/v1/proxy/referrals", tags=["Proxy"], summary="List proxy provider affiliate referrals")
|
||||
async def list_proxy_referrals() -> dict[str, Any]:
|
||||
"""Return the curated proxy provider affiliate catalog (proxy_referrals.py).
|
||||
|
||||
This is the marketing-friendly subset: commission, promo codes, tier
|
||||
(premium/standard/budget), and referral URLs. Useful for a "Sign up via Pry
|
||||
and we get a cut" UI, or for showing users premium options when their free
|
||||
proxy fails.
|
||||
|
||||
The full connection metadata (host, port, auth) lives in /v1/proxy/providers.
|
||||
"""
|
||||
from proxy_manager import ProxyManager
|
||||
|
||||
pm = ProxyManager()
|
||||
return {
|
||||
"success": True,
|
||||
"data": {
|
||||
"providers": pm.list_proxy_referrals(),
|
||||
"summary": pm.get_proxy_referral_summary(),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@app.get("/v1/proxy/referrals/{tag}", tags=["Proxy"], summary="Get a single proxy provider referral")
|
||||
async def get_proxy_referral(tag: str) -> dict[str, Any]:
|
||||
"""Return the affiliate info for a single proxy provider by tag."""
|
||||
from proxy_manager import ProxyManager
|
||||
|
||||
pm = ProxyManager()
|
||||
info = pm.get_proxy_referral(tag)
|
||||
if not info:
|
||||
return {"success": False, "error": f"No proxy referral found for tag: {tag}"}
|
||||
return {"success": True, "data": {"tag": tag, **info}}
|
||||
|
||||
|
||||
@app.post("/v1/proxy/configure", tags=["Proxy"], summary="Configure proxy credentials")
|
||||
async def proxy_configure(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue