syntax = "proto3";
option go_package = "./pb";

package pb;

import "models/rpc_messages.proto";
import "models/model_dns_domain.proto";
import "models/model_dns_route.proto";

// DNS域名相关
service DNSDomainService {
	// 创建域名
	rpc createDNSDomain (CreateDNSDomainRequest) returns (CreateDNSDomainResponse);

	// 修改域名
	rpc updateDNSDomain (UpdateDNSDomainRequest) returns (RPCSuccess);

	// 删除域名
	rpc deleteDNSDomain (DeleteDNSDomainRequest) returns (RPCSuccess);

	// 恢复删除的域名
	rpc recoverDNSDomain (RecoverDNSDomainRequest) returns (RPCSuccess);

	// 查询单个域名完整信息
	rpc findDNSDomain (FindDNSDomainRequest) returns (FindDNSDomainResponse);

	// 查询单个域名基础信息
	rpc findBasicDNSDomain (FindBasicDNSDomainRequest) returns (FindBasicDNSDomainResponse);

	// 计算服务商下的域名数量
	rpc countAllDNSDomainsWithDNSProviderId (CountAllDNSDomainsWithDNSProviderIdRequest) returns (RPCCountResponse);

	// 列出服务商下的所有域名
	rpc findAllDNSDomainsWithDNSProviderId (FindAllDNSDomainsWithDNSProviderIdRequest) returns (FindAllDNSDomainsWithDNSProviderIdResponse);

	// 列出服务商下的所有域名基本信息
	rpc findAllBasicDNSDomainsWithDNSProviderId (FindAllBasicDNSDomainsWithDNSProviderIdRequest) returns (FindAllBasicDNSDomainsWithDNSProviderIdResponse);

	// 列出服务商下的单页域名信息
	rpc listBasicDNSDomainsWithDNSProviderId (ListBasicDNSDomainsWithDNSProviderIdRequest) returns (ListDNSDomainsWithDNSProviderIdResponse);

	// 同步域名解析
	rpc syncDNSDomainData (SyncDNSDomainDataRequest) returns (SyncDNSDomainDataResponse);

	// 查看支持的线路
	rpc findAllDNSDomainRoutes (FindAllDNSDomainRoutesRequest) returns (FindAllDNSDomainRoutesResponse);

	// 判断是否有域名可选
	rpc existAvailableDomains (ExistAvailableDomainsRequest) returns (ExistAvailableDomainsResponse);

	// 检查域名是否在记录中
	rpc existDNSDomainRecord (ExistDNSDomainRecordRequest) returns (ExistDNSDomainRecordResponse);

	// 从服务商同步域名
	rpc syncDNSDomainsFromProvider(SyncDNSDomainsFromProviderRequest) returns (SyncDNSDomainsFromProviderResponse);
}

// 创建域名
message CreateDNSDomainRequest {
	int64 dnsProviderId = 1;
	string name = 2;
}

message CreateDNSDomainResponse {
	int64 dnsDomainId = 1;
}

// 修改域名
message UpdateDNSDomainRequest {
	int64 dnsDomainId = 1;
	string name = 2;
	bool isOn = 3;
}

// 删除域名
message DeleteDNSDomainRequest {
	int64 dnsDomainId = 1;
}

// 恢复删除的域名
message RecoverDNSDomainRequest {
	int64 dnsDomainId = 1;
}

// 查询单个域名信息
message FindDNSDomainRequest {
	int64 dnsDomainId = 1;
}

message FindDNSDomainResponse {
	DNSDomain dnsDomain = 1;
}

// 查询单个域名的基础信息
message FindBasicDNSDomainRequest {
	int64 dnsDomainId = 1;
}

message FindBasicDNSDomainResponse {
	DNSDomain dnsDomain = 1;
}

// 计算服务商下的域名数量
message CountAllDNSDomainsWithDNSProviderIdRequest {
	int64 dnsProviderId = 1;
	bool isDeleted = 2;
	bool isDown = 3;
}

// 列出服务商下的所有域名
message FindAllDNSDomainsWithDNSProviderIdRequest {
	int64 dnsProviderId = 1;
}

message FindAllDNSDomainsWithDNSProviderIdResponse {
	repeated DNSDomain dnsDomains = 1;
}

// 列出服务商下的所有域名基本信息
message FindAllBasicDNSDomainsWithDNSProviderIdRequest {
	int64 dnsProviderId = 1;
}

message FindAllBasicDNSDomainsWithDNSProviderIdResponse {
	repeated DNSDomain dnsDomains = 1;
}

// 列出服务商下的单页域名信息
message ListBasicDNSDomainsWithDNSProviderIdRequest {
	int64 dnsProviderId = 1;
	bool isDeleted = 2;
	bool isDown = 3;
	int64 offset = 4;
	int64 size = 5;
}

message ListDNSDomainsWithDNSProviderIdResponse {
	repeated DNSDomain dnsDomains = 1;
}

// 同步域名数据
message SyncDNSDomainDataRequest {
	int64 dnsDomainId = 1;
	int64 nodeClusterId = 2; // 如果指定，表示只更新单个集群ID
	bool checkNodeIssues = 3; // 是否检查节点问题
}

message SyncDNSDomainDataResponse {
	bool isOk = 1;
	string error = 2;
	bool shouldFix = 3;
}

// 查看支持的线路
message FindAllDNSDomainRoutesRequest {
	int64 dnsDomainId = 1;
}

message FindAllDNSDomainRoutesResponse {
	repeated DNSRoute routes = 1;
}

// 判断是否有域名可选
message ExistAvailableDomainsRequest {

}

message ExistAvailableDomainsResponse {
	bool exist = 1;
}

// 检查域名是否在记录中
message ExistDNSDomainRecordRequest {
	int64 dnsDomainId = 1;
	string name = 2;
	string type = 3; // 解析类型，比如A, CNAME等
	string route = 4; // 线路
	string value = 5; // 值
}

message ExistDNSDomainRecordResponse {
	bool isOk = 1;
}

// 从服务商同步域名
message SyncDNSDomainsFromProviderRequest {
	int64 dnsProviderId = 1;
}

message SyncDNSDomainsFromProviderResponse {
	bool hasChanges = 1;
}