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 findEnabledDNSDomain (FindEnabledDNSDomainRequest) returns (FindEnabledDNSDomainResponse);

	// 查询单个域名基础信息
	rpc findEnabledBasicDNSDomain (FindEnabledBasicDNSDomainRequest) returns (FindEnabledBasicDNSDomainResponse);

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

	// 列出服务商下的所有域名
	rpc findAllEnabledDNSDomainsWithDNSProviderId (FindAllEnabledDNSDomainsWithDNSProviderIdRequest) returns (FindAllEnabledDNSDomainsWithDNSProviderIdResponse);

	// 列出服务商下的所有域名基本信息
	rpc findAllEnabledBasicDNSDomainsWithDNSProviderId (FindAllEnabledBasicDNSDomainsWithDNSProviderIdRequest) returns (FindAllEnabledBasicDNSDomainsWithDNSProviderIdResponse);

	// 同步域名解析
	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 FindEnabledDNSDomainRequest {
	int64 dnsDomainId = 1;
}

message FindEnabledDNSDomainResponse {
	DNSDomain dnsDomain = 1;
}

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

message FindEnabledBasicDNSDomainResponse {
	DNSDomain dnsDomain = 1;
}

// 计算服务商下的域名数量
message CountAllEnabledDNSDomainsWithDNSProviderIdRequest {
	int64 dnsProviderId = 1;
}

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

message FindAllEnabledDNSDomainsWithDNSProviderIdResponse {
	repeated DNSDomain dnsDomains = 1;
}

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

message FindAllEnabledBasicDNSDomainsWithDNSProviderIdResponse {
	repeated DNSDomain dnsDomains = 1;
}

// 同步域名数据
message SyncDNSDomainDataRequest {
	int64 dnsDomainId = 1;
	int64 nodeClusterId = 2; // 如果指定，表示只更新单个集群ID
}

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;
}