Bind NPM clients to configured endpoints

This commit is contained in:
Lyncoln
2026-09-19 16:58:15 -04:00
parent d4d200551e
commit 79342590ba
2 changed files with 90 additions and 2 deletions
+15 -2
View File
@@ -4,12 +4,22 @@ from typing import Any
import requests
import urllib3
from .adapters import Endpoint
class NpmClient:
"""Authenticated client for the Nginx Proxy Manager API."""
def __init__(self, config):
def __init__(
self,
config,
endpoint: Endpoint | None = None,
):
self.config = config
self.endpoint = endpoint or config.npm_endpoints[0]
if self.endpoint.plugin != "npm":
raise RuntimeError("NpmClient requires an npm endpoint")
self.identity = os.getenv("NPM_IDENTITY")
self.secret = os.getenv("NPM_SECRET")
@@ -30,7 +40,10 @@ class NpmClient:
@property
def api_url(self) -> str:
return f"{self.config.proxy_url}/api"
return (
f"{self.config.proxy_api_scheme}://"
f"{self.endpoint.address}/api"
)
def login(self) -> None:
response = self.session.post(