syntax = "proto3";

option go_package = "github.com/canonical/ubuntu-desktop-provision/provd/proto";

package active_directory;

import "google/protobuf/empty.proto";

service ActiveDirectoryService {
    rpc HasSupport(google.protobuf.Empty) returns (HasSupportResponse);
    rpc IsUsed(google.protobuf.Empty) returns (IsUsedResponse);
    rpc SetUsed(SetUsedRequest) returns (google.protobuf.Empty);
    rpc GetConnectionInfo(google.protobuf.Empty) returns (GetConnectionInfoResponse);
    rpc SetConnectionInfo(SetConnectionInfoRequest) returns (google.protobuf.Empty);
    rpc CheckDomainName(CheckDomainNameRequest) returns (CheckDomainNameResponse);
    rpc CheckAdminName(CheckAdminNameRequest) returns (CheckAdminNameResponse);
    rpc CheckPassword(CheckPasswordRequest) returns (CheckPasswordResponse);
    rpc PingDomainController(PingDomainControllerRequest) returns (PingDomainControllerResponse);
    rpc GetJoinResult(GetJoinResultRequest) returns (GetJoinResultResponse);
}

message HasSupportResponse {
    bool has_support = 1;
}

message IsUsedResponse {
    bool is_used = 1;
}

message SetUsedRequest {
    bool is_used = 1;
}

message GetConnectionInfoResponse {
    AdConnectionInfo ad_connection_info = 1;
}

message SetConnectionInfoRequest {
    AdConnectionInfo ad_connection_info = 1;
}

message CheckAdminNameRequest {
    string admin_name = 1;
}

message CheckAdminNameResponse {
    enum AdAdminNameValidation {
        OK = 0;
        EMPTY = 1;
        INVALID_CHARS = 2;
    }
    AdAdminNameValidation validation = 1;
}

message CheckPasswordRequest {
    string password = 1;
}

message CheckPasswordResponse {
    enum AdPasswordValidation {
        OK = 0;
        EMPTY = 1;
    }
    AdPasswordValidation validation = 1;
}

message CheckDomainNameRequest {
    string domain_name = 1;
}

message CheckDomainNameResponse {
    repeated AdDomainNameValidation validation = 1;
}

message PingDomainControllerRequest {
    string domain = 1;
}

message PingDomainControllerResponse {
    AdDomainNameValidation validation= 1;
}

message GetJoinResultRequest {
    AdConnectionInfo ad_connection_info = 1;
}

message GetJoinResultResponse {
    enum AdJoinResult {
        OK = 0;
        JOIN_ERROR = 1;
        EMPTY_HOSTNAME = 2;
        PAM_ERROR = 3;
        UNKNOWN = 4;
    }
    AdJoinResult join_result = 1;
}

message AdConnectionInfo {
    string domain_name = 1;
    string admin_name = 2;
    string password = 3;
}

enum AdDomainNameValidation {
    OK = 0;
    EMPTY = 1;
    TOO_LONG = 2;
    INVALID_CHARS = 3;
    START_DOT = 4;
    END_DOT = 5;
    START_HYPHEN = 6;
    END_HYPHEN = 7;
    MULTIPLE_DOTS = 8;
    REALM_NOT_FOUND = 9;
}
