mirror of
https://github.com/juanfont/headscale.git
synced 2025-12-03 06:22:25 -05:00
Add proto rpc interface for cli
This commit adds proto rpc definitions for the communication needed for the CLI interface. This will allow us to move the rest of the CLI interface over to gRPC and in the future allow remote access
This commit is contained in:
@@ -2,86 +2,19 @@ syntax = "proto3";
|
||||
package headscale.v1;
|
||||
option go_package = "github.com/juanfont/headscale/gen/go/v1";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
enum RegisterMethod {
|
||||
REGISTER_METHOD_UNSPECIFIED = 0;
|
||||
REGISTER_METHOD_AUTH_KEY = 1;
|
||||
REGISTER_METHOD_CLI = 2;
|
||||
REGISTER_METHOD_OIDC = 3;
|
||||
}
|
||||
|
||||
// message PreAuthKey {
|
||||
// uint64 id = 1;
|
||||
// string key = 2;
|
||||
// uint32 namespace_id = 3;
|
||||
// Namespace namespace = 4;
|
||||
// bool reusable = 5;
|
||||
// bool ephemeral = 6;
|
||||
// bool used = 7;
|
||||
//
|
||||
// google.protobuf.Timestamp created_at = 8;
|
||||
// google.protobuf.Timestamp expiration = 9;
|
||||
// }
|
||||
|
||||
message GetMachineRequest {
|
||||
uint64 machine_id = 1;
|
||||
}
|
||||
|
||||
message GetMachineResponse {
|
||||
uint64 id = 1;
|
||||
string machine_key = 2;
|
||||
string node_key = 3;
|
||||
string disco_key = 4;
|
||||
string ip_address = 5;
|
||||
string name = 6;
|
||||
uint32 namespace_id = 7;
|
||||
|
||||
bool registered = 8;
|
||||
RegisterMethod register_method = 9;
|
||||
uint32 auth_key_id = 10;
|
||||
// PreAuthKey auth_key = 11;
|
||||
|
||||
google.protobuf.Timestamp last_seen = 12;
|
||||
google.protobuf.Timestamp last_successful_update = 13;
|
||||
google.protobuf.Timestamp expiry = 14;
|
||||
|
||||
// bytes host_info = 15;
|
||||
// bytes endpoints = 16;
|
||||
// bytes enabled_routes = 17;
|
||||
|
||||
// google.protobuf.Timestamp created_at = 18;
|
||||
// google.protobuf.Timestamp updated_at = 19;
|
||||
// google.protobuf.Timestamp deleted_at = 20;
|
||||
}
|
||||
|
||||
message CreateNamespaceRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message CreateNamespaceResponse {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message DeleteNamespaceRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message DeleteNamespaceResponse {
|
||||
}
|
||||
|
||||
message ListNamespacesRequest {
|
||||
}
|
||||
|
||||
message ListNamespacesResponse {
|
||||
repeated string namespaces = 1;
|
||||
}
|
||||
import "headscale/v1/namespace.proto";
|
||||
import "headscale/v1/preauthkey.proto";
|
||||
import "headscale/v1/machine.proto";
|
||||
import "headscale/v1/routes.proto";
|
||||
// import "headscale/v1/device.proto";
|
||||
|
||||
service HeadscaleService {
|
||||
rpc GetMachine(GetMachineRequest) returns(GetMachineResponse) {
|
||||
// --- Namespace start ---
|
||||
rpc GetNamespace(GetNamespaceRequest) returns(GetNamespaceResponse) {
|
||||
option(google.api.http) = {
|
||||
get : "/api/v1/machine/{machine_id}"
|
||||
get : "/api/v1/namespace/{name}"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -92,9 +25,15 @@ service HeadscaleService {
|
||||
};
|
||||
}
|
||||
|
||||
rpc RenameNamespace(RenameNamespaceRequest) returns(RenameNamespaceResponse) {
|
||||
option(google.api.http) = {
|
||||
post : "/api/v1/namespace/{old_name}/rename/{new_name}"
|
||||
};
|
||||
}
|
||||
|
||||
rpc DeleteNamespace(DeleteNamespaceRequest) returns(DeleteNamespaceResponse) {
|
||||
option(google.api.http) = {
|
||||
delete : "/api/v1/namespace"
|
||||
delete : "/api/v1/namespace/{name}"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -103,4 +42,111 @@ service HeadscaleService {
|
||||
get : "/api/v1/namespace"
|
||||
};
|
||||
}
|
||||
// --- Namespace end ---
|
||||
|
||||
// --- PreAuthKeys start ---
|
||||
rpc CreatePreAuthKey(CreatePreAuthKeyRequest) returns(CreatePreAuthKeyResponse) {
|
||||
option(google.api.http) = {
|
||||
post : "/api/v1/preauthkey"
|
||||
body : "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ExpirePreAuthKey(ExpirePreAuthKeyRequest) returns(ExpirePreAuthKeyResponse) {
|
||||
option(google.api.http) = {
|
||||
post : "/api/v1/preauthkey/expire"
|
||||
body : "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ListPreAuthKeys(ListPreAuthKeysRequest) returns(ListPreAuthKeysResponse) {
|
||||
option(google.api.http) = {
|
||||
get : "/api/v1/preauthkey"
|
||||
};
|
||||
}
|
||||
// --- PreAuthKeys end ---
|
||||
|
||||
// --- Machine start ---
|
||||
rpc DebugCreateMachine(DebugCreateMachineRequest) returns(DebugCreateMachineResponse) {
|
||||
option(google.api.http) = {
|
||||
post : "/api/v1/debug/machine"
|
||||
body : "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc GetMachine(GetMachineRequest) returns(GetMachineResponse) {
|
||||
option(google.api.http) = {
|
||||
get : "/api/v1/machine/{machine_id}"
|
||||
};
|
||||
}
|
||||
|
||||
rpc RegisterMachine(RegisterMachineRequest) returns(RegisterMachineResponse) {
|
||||
option(google.api.http) = {
|
||||
post : "/api/v1/machine/register"
|
||||
};
|
||||
}
|
||||
|
||||
rpc DeleteMachine(DeleteMachineRequest) returns(DeleteMachineResponse) {
|
||||
option(google.api.http) = {
|
||||
delete : "/api/v1/machine/{machine_id}"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ListMachines(ListMachinesRequest) returns(ListMachinesResponse) {
|
||||
option(google.api.http) = {
|
||||
get : "/api/v1/machine"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ShareMachine(ShareMachineRequest) returns(ShareMachineResponse) {
|
||||
option(google.api.http) = {
|
||||
post : "/api/v1/machine/{machine_id}/share/{namespace}"
|
||||
};
|
||||
}
|
||||
|
||||
rpc UnshareMachine(UnshareMachineRequest) returns(UnshareMachineResponse) {
|
||||
option(google.api.http) = {
|
||||
post : "/api/v1/machine/{machine_id}/unshare/{namespace}"
|
||||
};
|
||||
}
|
||||
// --- Machine end ---
|
||||
|
||||
// --- Route start ---
|
||||
rpc GetMachineRoute(GetMachineRouteRequest) returns(GetMachineRouteResponse) {
|
||||
option(google.api.http) = {
|
||||
get : "/api/v1/machine/{machine_id}/routes"
|
||||
};
|
||||
}
|
||||
|
||||
rpc EnableMachineRoutes(EnableMachineRoutesRequest) returns(EnableMachineRoutesResponse) {
|
||||
option(google.api.http) = {
|
||||
post : "/api/v1/machine/{machine_id}/routes"
|
||||
};
|
||||
}
|
||||
// --- Route end ---
|
||||
|
||||
// Implement Tailscale API
|
||||
// rpc GetDevice(GetDeviceRequest) returns(GetDeviceResponse) {
|
||||
// option(google.api.http) = {
|
||||
// get : "/api/v1/device/{id}"
|
||||
// };
|
||||
// }
|
||||
|
||||
// rpc DeleteDevice(DeleteDeviceRequest) returns(DeleteDeviceResponse) {
|
||||
// option(google.api.http) = {
|
||||
// delete : "/api/v1/device/{id}"
|
||||
// };
|
||||
// }
|
||||
|
||||
// rpc GetDeviceRoutes(GetDeviceRoutesRequest) returns(GetDeviceRoutesResponse) {
|
||||
// option(google.api.http) = {
|
||||
// get : "/api/v1/device/{id}/routes"
|
||||
// };
|
||||
// }
|
||||
|
||||
// rpc EnableDeviceRoutes(EnableDeviceRoutesRequest) returns(EnableDeviceRoutesResponse) {
|
||||
// option(google.api.http) = {
|
||||
// post : "/api/v1/device/{id}/routes"
|
||||
// };
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user