Headscale API client
Go to file
Andrea Mistrali 5d90f74b38
Bump version
2024-12-17 12:07:48 +01:00
hsapi_client Fix policy upload 2024-12-17 12:06:47 +01:00
.gitignore Builds 2024-07-04 15:28:00 +02:00
.python-version First working version 2024-06-27 16:31:55 +02:00
LICENSE Reorganize repos 2024-07-23 09:15:03 +02:00
README.md Update README 2024-07-23 12:01:45 +02:00
TODO.md Reorganize repos 2024-07-23 09:15:03 +02:00
headscale.openapi.json Support for policies (ro) 2024-10-04 12:57:12 +02:00
poetry.lock Support for policies (ro) 2024-10-04 12:57:12 +02:00
pyproject.toml Bump version 2024-12-17 12:07:48 +01:00

README.md

Headscale API client

This module is a client for Headscale API. It can manage all the entities of headscale, namely:

  • nodes
  • users
  • routes
  • preauthkeys
  • apikeys

Wherever it was possible I used python data types, for example datetime is used for all the dates, while int is used for all IDs;

Schemas

Using the OpenAPI specs provided by headscale, I converted them to python classes, so you can refer to the Headscale OpenAPI specification in file headscale.openapi.json for more details, but I will try to provide a list of classes and methods available.

Nodes

Methods:

  • list: list all the nodes registered on headscale;
  • get: retrieve a specific node by its ID
  • byUser: retrieve all the nodes of a user, given the username;
  • delete: deletes a node, by ID;
  • expire: expire (disconnect) a node, by ID;
  • rename: rename a node, by ID;
  • move: assing a nide to a new user;
  • routes: retrieve all the routes announced by a node;
  • setTags: set tags for a node;
  • backfillips: (currently broken in Headscale), fills the nodes table with all the IPs, to be used in rare cases;

Properties:

  • expired: if the node is expired;
  • expireDate: when the node is going to expire;

Users

Methods:

  • list: list all users'
  • get: get a user, by ID;
  • create: create a new user, given a username;
  • delete: delete a user, given the username;
  • rename: rename a user, given the current and the new username;

Routes

Methods:

  • list: get all routes;
  • delete: deletes a route, given the ID;
  • enable: enable a route, given the ID;
  • disable: disable a route given the ID;

API Keys

Methods:

  • list: list all the API keys;
  • create: create a new API key;
  • expire: invalidates a new API key;
  • delete: delete an API key;

PreAuth keys

Methods

  • list: list all the preauth keys for a user;
  • create: create a new preauth key for a user;
  • expire: expires (invalidates) a preauth key for a user;

Configuration

To be able to access headscale the module needs the URL of the headscale portal and an API key. These values are provided via environment variables, specifically:

  • HSAPI_SERVER
  • HSAPI_API_TOKEN