syntax = "proto3";
package headscale.v1;
option  go_package = "github.com/juanfont/headscale/gen/go/v1";

import "google/protobuf/timestamp.proto";
import "headscale/v1/user.proto";
import "headscale/v1/preauthkey.proto";

enum RegisterMethod {
    REGISTER_METHOD_UNSPECIFIED = 0;
    REGISTER_METHOD_AUTH_KEY    = 1;
    REGISTER_METHOD_CLI         = 2;
    REGISTER_METHOD_OIDC        = 3;
}

message Machine {
    uint64          id           = 1;
    string          machine_key  = 2;
    string          node_key     = 3;
    string          disco_key    = 4;
    repeated string ip_addresses = 5;
    string          name         = 6;
    User user          = 7;

    google.protobuf.Timestamp last_seen              = 8;
    google.protobuf.Timestamp last_successful_update = 9;
    google.protobuf.Timestamp expiry                 = 10;

    PreAuthKey pre_auth_key = 11;

    google.protobuf.Timestamp created_at = 12;

    RegisterMethod register_method = 13;

    reserved 14 to 17;
    // google.protobuf.Timestamp updated_at = 14;
    // google.protobuf.Timestamp deleted_at = 15;

    // bytes host_info      = 15;
    // bytes endpoints      = 16;
    // bytes enabled_routes = 17;

    repeated string forced_tags  = 18;
    repeated string invalid_tags = 19;
    repeated string valid_tags   = 20;
    string          given_name   = 21;
    bool            online       = 22;
}

message RegisterMachineRequest {
    string user = 1;
    string key       = 2;
}

message RegisterMachineResponse {
    Machine machine = 1;
}

message GetMachineRequest {
    uint64 machine_id = 1;
}

message GetMachineResponse {
    Machine machine = 1;
}

message SetTagsRequest {
    uint64          machine_id = 1;
    repeated string tags       = 2;
}

message SetTagsResponse {
    Machine machine = 1;
}

message DeleteMachineRequest {
    uint64 machine_id = 1;
}

message DeleteMachineResponse {
}

message ExpireMachineRequest {
    uint64 machine_id = 1;
}

message ExpireMachineResponse {
    Machine machine = 1;
}

message RenameMachineRequest {
    uint64 machine_id = 1;
    string new_name   = 2;
}

message RenameMachineResponse {
    Machine machine = 1;
}

message ListMachinesRequest {
    string user = 1;
}

message ListMachinesResponse {
    repeated Machine machines = 1;
}

message MoveMachineRequest {
    uint64 machine_id = 1;
    string user  = 2;
}

message MoveMachineResponse {
    Machine machine = 1;
}

message DebugCreateMachineRequest {
    string user       = 1;
    string          key    = 2;
    string          name   = 3;
    repeated string routes = 4;
}

message DebugCreateMachineResponse {
    Machine machine = 1;
}