Bind NPM clients to configured endpoints
This commit is contained in:
+15
-2
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user