Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions dkg/providers/node_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@


class NodeHTTPProvider:
def __init__(self, endpoint_uri: URI | str, auth_token: str | None = None):
def __init__(
self,
endpoint_uri: URI | str,
auth_token: str | None = None,
api_version: str = "v0",
):
self.endpoint_uri = URI(endpoint_uri)
self.auth_token = auth_token
self.api_version = api_version

def get_full_url(self, path: str) -> str:
return f"{self.endpoint_uri}/{self.api_version}/{path}"

def make_request(
self,
Expand All @@ -36,7 +45,7 @@ def make_request(
params: dict[str, Any] = {},
data: dict[str, Any] = {},
) -> NodeResponseDict:
url = f"{self.endpoint_uri}/{path}"
url = self.get_full_url(path)
headers = (
{"Authorization": f"Bearer {self.auth_token}"} if self.auth_token else {}
)
Expand Down