Changed FS structure, add initial hsman directory
This commit is contained in:
parent
e90cac77db
commit
089de6685e
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
from typing import Optional, Union
|
||||
from typing import Union
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
@ -8,11 +8,11 @@ class APISettings(BaseSettings):
|
|||
model_config = SettingsConfigDict(env_prefix='HS_')
|
||||
server: str = "http://localhost:8080"
|
||||
api_path: str = "/api/v1"
|
||||
api_token: Union[str, None] = None
|
||||
ssl_verify: Union[bool, str] = True
|
||||
api_token: Union[None, str] = None
|
||||
|
||||
def refresh_api_token(self):
|
||||
self.api_token = os.environ.get('HS_API_TOKEN')
|
||||
self.api_token = os.environ.get('HS_API_TOKEN', 'default')
|
||||
|
||||
|
||||
class HTTPException(Exception):
|
|
@ -28,11 +28,8 @@ class HSAPICall:
|
|||
|
||||
objectPath: str = ""
|
||||
|
||||
def __init__(self, api_settings_override: Optional[APISettings] = None) -> None:
|
||||
if api_settings_override:
|
||||
self.api_settings = api_settings_override
|
||||
else:
|
||||
self.api_settings = APISettings()
|
||||
def __init__(self, settings: Optional[APISettings] = None) -> None:
|
||||
self.api_settings = settings if settings else APISettings()
|
||||
self.base_path = f"{
|
||||
self.api_settings.server}{self.api_settings.api_path}/{self.objectPath}"
|
||||
|
||||
|
@ -61,7 +58,7 @@ class HSAPICall:
|
|||
json=json_
|
||||
)
|
||||
if response.status_code != 200:
|
||||
raise HTTPException(response.status_code, f" failed with status code: {
|
||||
raise HTTPException(response.status_code, f" failed. Error: {
|
||||
response.text}")
|
||||
|
||||
return response
|
|
@ -1,7 +1,7 @@
|
|||
[tool.poetry]
|
||||
name = "headscale-api-client"
|
||||
version = "0.1.0"
|
||||
description = "Headscale API module"
|
||||
name = "hsapi"
|
||||
version = "0.9.0"
|
||||
description = "Headscale API client"
|
||||
authors = ["Andrea Mistrali <andrea@mistrali.pw>"]
|
||||
license = "BSD"
|
||||
readme = "README.md"
|
Loading…
Reference in New Issue