1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-11-10 01:20:58 +01:00

update user api to use IDs over names

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2024-12-05 09:51:08 +01:00
parent 4967d87408
commit 273483a310
No known key found for this signature in database
2 changed files with 210 additions and 225 deletions

View File

@ -1,6 +1,6 @@
syntax = "proto3"; syntax = "proto3";
package headscale.v1; package headscale.v1;
option go_package = "github.com/juanfont/headscale/gen/go/v1"; option go_package = "github.com/juanfont/headscale/gen/go/v1";
import "google/api/annotations.proto"; import "google/api/annotations.proto";
@ -13,225 +13,226 @@ import "headscale/v1/policy.proto";
// import "headscale/v1/device.proto"; // import "headscale/v1/device.proto";
service HeadscaleService { service HeadscaleService {
// --- User start --- // --- User start ---
rpc GetUser(GetUserRequest) returns (GetUserResponse) { rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) {
option (google.api.http) = { option (google.api.http) = {
get: "/api/v1/user/{name}" post : "/api/v1/user"
}; body : "*"
} };
}
rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) { rpc RenameUser(RenameUserRequest) returns (RenameUserResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/user" post : "/api/v1/user/{old_id}/rename/{new_name}"
body: "*" };
}; }
}
rpc RenameUser(RenameUserRequest) returns (RenameUserResponse) { rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/user/{old_name}/rename/{new_name}" delete : "/api/v1/user/{id}"
}; };
} }
rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse) { rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) {
option (google.api.http) = { option (google.api.http) = {
delete: "/api/v1/user/{name}" get : "/api/v1/user"
}; };
} }
// --- User end ---
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) { // --- PreAuthKeys start ---
option (google.api.http) = { rpc CreatePreAuthKey(CreatePreAuthKeyRequest)
get: "/api/v1/user" returns (CreatePreAuthKeyResponse) {
}; option (google.api.http) = {
} post : "/api/v1/preauthkey"
// --- User end --- body : "*"
};
}
// --- PreAuthKeys start --- rpc ExpirePreAuthKey(ExpirePreAuthKeyRequest)
rpc CreatePreAuthKey(CreatePreAuthKeyRequest) returns (CreatePreAuthKeyResponse) { returns (ExpirePreAuthKeyResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/preauthkey" post : "/api/v1/preauthkey/expire"
body: "*" body : "*"
}; };
} }
rpc ExpirePreAuthKey(ExpirePreAuthKeyRequest) returns (ExpirePreAuthKeyResponse) { rpc ListPreAuthKeys(ListPreAuthKeysRequest)
option (google.api.http) = { returns (ListPreAuthKeysResponse) {
post: "/api/v1/preauthkey/expire" option (google.api.http) = {
body: "*" get : "/api/v1/preauthkey"
}; };
} }
// --- PreAuthKeys end ---
rpc ListPreAuthKeys(ListPreAuthKeysRequest) returns (ListPreAuthKeysResponse) { // --- Node start ---
option (google.api.http) = { rpc DebugCreateNode(DebugCreateNodeRequest)
get: "/api/v1/preauthkey" returns (DebugCreateNodeResponse) {
}; option (google.api.http) = {
} post : "/api/v1/debug/node"
// --- PreAuthKeys end --- body : "*"
};
}
// --- Node start --- rpc GetNode(GetNodeRequest) returns (GetNodeResponse) {
rpc DebugCreateNode(DebugCreateNodeRequest) returns (DebugCreateNodeResponse) { option (google.api.http) = {
option (google.api.http) = { get : "/api/v1/node/{node_id}"
post: "/api/v1/debug/node" };
body: "*" }
};
}
rpc GetNode(GetNodeRequest) returns (GetNodeResponse) { rpc SetTags(SetTagsRequest) returns (SetTagsResponse) {
option (google.api.http) = { option (google.api.http) = {
get: "/api/v1/node/{node_id}" post : "/api/v1/node/{node_id}/tags"
}; body : "*"
} };
}
rpc SetTags(SetTagsRequest) returns (SetTagsResponse) { rpc RegisterNode(RegisterNodeRequest) returns (RegisterNodeResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/node/{node_id}/tags" post : "/api/v1/node/register"
body: "*" };
}; }
}
rpc RegisterNode(RegisterNodeRequest) returns (RegisterNodeResponse) { rpc DeleteNode(DeleteNodeRequest) returns (DeleteNodeResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/node/register" delete : "/api/v1/node/{node_id}"
}; };
} }
rpc DeleteNode(DeleteNodeRequest) returns (DeleteNodeResponse) { rpc ExpireNode(ExpireNodeRequest) returns (ExpireNodeResponse) {
option (google.api.http) = { option (google.api.http) = {
delete: "/api/v1/node/{node_id}" post : "/api/v1/node/{node_id}/expire"
}; };
} }
rpc ExpireNode(ExpireNodeRequest) returns (ExpireNodeResponse) { rpc RenameNode(RenameNodeRequest) returns (RenameNodeResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/node/{node_id}/expire" post : "/api/v1/node/{node_id}/rename/{new_name}"
}; };
} }
rpc RenameNode(RenameNodeRequest) returns (RenameNodeResponse) { rpc ListNodes(ListNodesRequest) returns (ListNodesResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/node/{node_id}/rename/{new_name}" get : "/api/v1/node"
}; };
} }
rpc ListNodes(ListNodesRequest) returns (ListNodesResponse) { rpc MoveNode(MoveNodeRequest) returns (MoveNodeResponse) {
option (google.api.http) = { option (google.api.http) = {
get: "/api/v1/node" post : "/api/v1/node/{node_id}/user",
}; body : "*"
} };
}
rpc MoveNode(MoveNodeRequest) returns (MoveNodeResponse) { rpc BackfillNodeIPs(BackfillNodeIPsRequest)
option (google.api.http) = { returns (BackfillNodeIPsResponse) {
post: "/api/v1/node/{node_id}/user", option (google.api.http) = {
body: "*" post : "/api/v1/node/backfillips"
}; };
} }
rpc BackfillNodeIPs(BackfillNodeIPsRequest) returns (BackfillNodeIPsResponse) { // --- Node end ---
option (google.api.http) = {
post: "/api/v1/node/backfillips"
};
}
// --- Node end --- // --- Route start ---
rpc GetRoutes(GetRoutesRequest) returns (GetRoutesResponse) {
option (google.api.http) = {
get : "/api/v1/routes"
};
}
// --- Route start --- rpc EnableRoute(EnableRouteRequest) returns (EnableRouteResponse) {
rpc GetRoutes(GetRoutesRequest) returns (GetRoutesResponse) { option (google.api.http) = {
option (google.api.http) = { post : "/api/v1/routes/{route_id}/enable"
get: "/api/v1/routes" };
}; }
}
rpc EnableRoute(EnableRouteRequest) returns (EnableRouteResponse) { rpc DisableRoute(DisableRouteRequest) returns (DisableRouteResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/routes/{route_id}/enable" post : "/api/v1/routes/{route_id}/disable"
}; };
} }
rpc DisableRoute(DisableRouteRequest) returns (DisableRouteResponse) { rpc GetNodeRoutes(GetNodeRoutesRequest) returns (GetNodeRoutesResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/routes/{route_id}/disable" get : "/api/v1/node/{node_id}/routes"
}; };
} }
rpc GetNodeRoutes(GetNodeRoutesRequest) returns (GetNodeRoutesResponse) { rpc DeleteRoute(DeleteRouteRequest) returns (DeleteRouteResponse) {
option (google.api.http) = { option (google.api.http) = {
get: "/api/v1/node/{node_id}/routes" delete : "/api/v1/routes/{route_id}"
}; };
} }
rpc DeleteRoute(DeleteRouteRequest) returns (DeleteRouteResponse) { // --- Route end ---
option (google.api.http) = {
delete: "/api/v1/routes/{route_id}"
};
}
// --- Route end --- // --- ApiKeys start ---
rpc CreateApiKey(CreateApiKeyRequest) returns (CreateApiKeyResponse) {
option (google.api.http) = {
post : "/api/v1/apikey"
body : "*"
};
}
// --- ApiKeys start --- rpc ExpireApiKey(ExpireApiKeyRequest) returns (ExpireApiKeyResponse) {
rpc CreateApiKey(CreateApiKeyRequest) returns (CreateApiKeyResponse) { option (google.api.http) = {
option (google.api.http) = { post : "/api/v1/apikey/expire"
post: "/api/v1/apikey" body : "*"
body: "*" };
}; }
}
rpc ExpireApiKey(ExpireApiKeyRequest) returns (ExpireApiKeyResponse) { rpc ListApiKeys(ListApiKeysRequest) returns (ListApiKeysResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/apikey/expire" get : "/api/v1/apikey"
body: "*" };
}; }
}
rpc ListApiKeys(ListApiKeysRequest) returns (ListApiKeysResponse) { rpc DeleteApiKey(DeleteApiKeyRequest) returns (DeleteApiKeyResponse) {
option (google.api.http) = { option (google.api.http) = {
get: "/api/v1/apikey" delete : "/api/v1/apikey/{prefix}"
}; };
} }
// --- ApiKeys end ---
rpc DeleteApiKey(DeleteApiKeyRequest) returns (DeleteApiKeyResponse) { // --- Policy start ---
option (google.api.http) = { rpc GetPolicy(GetPolicyRequest) returns (GetPolicyResponse) {
delete: "/api/v1/apikey/{prefix}" option (google.api.http) = {
}; get : "/api/v1/policy"
} };
// --- ApiKeys end --- }
// --- Policy start --- rpc SetPolicy(SetPolicyRequest) returns (SetPolicyResponse) {
rpc GetPolicy(GetPolicyRequest) returns (GetPolicyResponse) { option (google.api.http) = {
option (google.api.http) = { put : "/api/v1/policy"
get: "/api/v1/policy" body : "*"
}; };
} }
// --- Policy end ---
rpc SetPolicy(SetPolicyRequest) returns (SetPolicyResponse) { // Implement Tailscale API
option (google.api.http) = { // rpc GetDevice(GetDeviceRequest) returns(GetDeviceResponse) {
put: "/api/v1/policy" // option(google.api.http) = {
body: "*" // get : "/api/v1/device/{id}"
}; // };
} // }
// --- Policy end ---
// Implement Tailscale API // rpc DeleteDevice(DeleteDeviceRequest) returns(DeleteDeviceResponse) {
// rpc GetDevice(GetDeviceRequest) returns(GetDeviceResponse) { // option(google.api.http) = {
// option(google.api.http) = { // delete : "/api/v1/device/{id}"
// get : "/api/v1/device/{id}" // };
// }; // }
// }
// rpc DeleteDevice(DeleteDeviceRequest) returns(DeleteDeviceResponse) { // rpc GetDeviceRoutes(GetDeviceRoutesRequest)
// option(google.api.http) = { // returns(GetDeviceRoutesResponse) {
// delete : "/api/v1/device/{id}" // option(google.api.http) = {
// }; // get : "/api/v1/device/{id}/routes"
// } // };
// }
// rpc GetDeviceRoutes(GetDeviceRoutesRequest) returns(GetDeviceRoutesResponse) { // rpc EnableDeviceRoutes(EnableDeviceRoutesRequest)
// option(google.api.http) = { // returns(EnableDeviceRoutesResponse) {
// get : "/api/v1/device/{id}/routes" // option(google.api.http) = {
// }; // post : "/api/v1/device/{id}/routes"
// } // };
// }
// rpc EnableDeviceRoutes(EnableDeviceRoutesRequest) returns(EnableDeviceRoutesResponse) {
// option(google.api.http) = {
// post : "/api/v1/device/{id}/routes"
// };
// }
} }

View File

@ -1,55 +1,39 @@
syntax = "proto3"; syntax = "proto3";
package headscale.v1; package headscale.v1;
option go_package = "github.com/juanfont/headscale/gen/go/v1"; option go_package = "github.com/juanfont/headscale/gen/go/v1";
import "google/protobuf/timestamp.proto"; import "google/protobuf/timestamp.proto";
message User { message User {
string id = 1; uint64 id = 1;
string name = 2; string name = 2;
google.protobuf.Timestamp created_at = 3; google.protobuf.Timestamp created_at = 3;
string display_name = 4; string display_name = 4;
string email = 5; string email = 5;
string provider_id = 6; string provider_id = 6;
string provider = 7; string provider = 7;
string profile_pic_url = 8; string profile_pic_url = 8;
} }
message GetUserRequest { message CreateUserRequest { string name = 1; }
string name = 1;
}
message GetUserResponse { message CreateUserResponse { User user = 1; }
User user = 1;
}
message CreateUserRequest {
string name = 1;
}
message CreateUserResponse {
User user = 1;
}
message RenameUserRequest { message RenameUserRequest {
string old_name = 1; uint64 old_id = 1;
string new_name = 2; string new_name = 2;
} }
message RenameUserResponse { message RenameUserResponse { User user = 1; }
User user = 1;
}
message DeleteUserRequest { message DeleteUserRequest { uint64 id = 1; }
string name = 1;
}
message DeleteUserResponse { message DeleteUserResponse {}
}
message ListUsersRequest { message ListUsersRequest {
uint64 id = 1;
string name = 2;
string email = 3;
} }
message ListUsersResponse { message ListUsersResponse { repeated User users = 1; }
repeated User users = 1;
}