Extracted from silo monorepo. Provides SiloClient (HTTP client) and SiloSettings (abstract config adapter) so both the FreeCAD workbench and LibreOffice Calc extension share the same API layer. Includes CATEGORY_NAMES, sanitize_filename, parse_part_number, get_category_folder_name, and SSL context builder.
37 lines
884 B
Markdown
37 lines
884 B
Markdown
# silo-client
|
|
|
|
Shared Python HTTP client for the Silo REST API.
|
|
|
|
## Usage
|
|
|
|
Consumers subclass `SiloSettings` to bridge the client to their configuration storage, then instantiate `SiloClient`:
|
|
|
|
```python
|
|
from silo_client import SiloClient, SiloSettings
|
|
|
|
class MySettings(SiloSettings):
|
|
def get_api_url(self):
|
|
return "http://localhost:8080/api"
|
|
def get_api_token(self):
|
|
return os.environ.get("SILO_API_TOKEN", "")
|
|
def get_ssl_verify(self):
|
|
return True
|
|
def get_ssl_cert_path(self):
|
|
return ""
|
|
def save_auth(self, username, role="", source="", token=""):
|
|
... # persist credentials
|
|
def clear_auth(self):
|
|
... # remove credentials
|
|
|
|
client = SiloClient(MySettings())
|
|
items = client.list_items(search="M3 screw")
|
|
```
|
|
|
|
## Dependencies
|
|
|
|
None beyond the Python standard library (`urllib`, `ssl`, `json`).
|
|
|
|
## License
|
|
|
|
MIT
|