syntax = "proto3";

package smtpd;

message UInt64Value {
	uint64 value = 1;
}

message DoubleValue {
	double value = 1;
}

message StringValue {
	string value = 1;
}

message StringRegexValue {
	string value = 1;
	enum MatchType {
		EXACT = 0;
		REGEX = 1;
	}
	MatchType type = 2;
}

message BoolValue {
	bool value = 1;
}

message TimeValue {
	oneof time {
		double absolute = 1;
		double relative = 2;
	}
}

enum Queue {
	ACTIVE = 0;
	DEFER = 1;
}

enum Freeze {
	HOLD = 0;
	UPDATE = 1;
}

enum Working {
	OTHER = 0;
	SENDING = 1;
}

enum ActionType {
	DELETE = 0;
	BOUNCE = 1;
}

enum Order {
	ASC = 0;
	DESC = 1;
}

enum TimeRound {
	EXACT = 0;
	FLOOR = 1;
}

message CompareTime {
	TimeValue eq = 1;
	TimeValue neq = 2;
	TimeValue lt = 3;
	TimeValue gt = 4;
	TimeValue gte = 5;
	TimeValue lte = 6;
	TimeRound round = 7;
}

message CompareUInt64 {
	UInt64Value eq = 1;
	UInt64Value neq = 2;
	UInt64Value lt = 3;
	UInt64Value gt = 4;
	UInt64Value gte = 5;
	UInt64Value lte = 6;
}

message CompareDouble {
	DoubleValue eq = 1;
	DoubleValue neq = 2;
	DoubleValue lt = 3;
	DoubleValue gt = 4;
	DoubleValue gte = 5;
	DoubleValue lte = 6;
}

message StringMatch {
	enum MatchType {
		EXACT = 0;
		PARTIAL = 1;
		REGEX = 2;
	}
	bool exclude = 1;
	string value = 2;
	MatchType type = 3;
	bool caseless = 4;
}

message VersionResponse
{
	uint64 major = 1;
	uint64 minor = 2;
	uint64 patch = 3;
}

message QueueItemID {
	string transaction = 1;
	uint64 queue = 2;
}

message Condition {
	message QueueItemID {
		string transaction = 1;
		uint64 queue = 2;
		bool exclude = 3;
	}
	message AnyMatch {
		repeated StringMatch string = 1;
		repeated CompareDouble double = 2;
	}
	message MailAddress {
		StringMatch localpart = 1;
		StringRegexValue domain = 2;
		bool exclude = 3;
	}
	message MapStringValue {
		map<string, AnyMatch> value = 1;
		bool exclude = 2;
	}
	message QueueState {
		Queue queue = 1;
	}
	message FreezeState {
		Freeze freeze = 1;
	}
	message WorkingState {
		Working working = 1;
		BoolValue updatefreezing = 2;
	}
	message CompareStringValue {
		string value = 2;
		bool exclude = 1;
	}
	message CompareStringRegexValue {
		string value = 2;
		bool exclude = 1;
		enum MatchType {
			EXACT = 0;
			REGEX = 1;
		}
		MatchType type = 3;
	}

	repeated QueueState queues = 1;
	repeated FreezeState freezes = 2;
	repeated WorkingState workings = 3;
	BoolValue suspended = 29;

	repeated QueueItemID ids = 4;
	BoolValue hold = 5;
	repeated CompareStringValue serverids = 6;
	repeated CompareStringValue senderips = 7;
	repeated CompareStringRegexValue transportids = 8;
	repeated CompareStringRegexValue jobids = 9;
	repeated CompareStringRegexValue groupings = 27;
	repeated CompareStringRegexValue tenantids = 30;
	repeated CompareStringValue stageids = 10;
	repeated MailAddress senders = 11;
	repeated MailAddress recipients = 12;
	repeated CompareTime tss = 13;
	repeated CompareTime retrytss = 14;
	repeated CompareUInt64 retrycounts = 15;
	repeated StringMatch subjects = 16;
	repeated MapStringValue metadatas = 17;
	repeated CompareStringValue quotas = 18;
	repeated CompareUInt64 sizes = 19;
	repeated StringMatch retryreasons = 20;
	repeated CompareStringValue localips = 21;
	bool localipexact = 31;
	repeated CompareStringValue remoteips = 22;
	repeated CompareStringRegexValue remotemxs = 23;
	repeated CompareStringValue tags = 24;
	repeated CompareUInt64 priorities = 25;
	float probability = 28;
	message Fields {
		bool transportid = 1;
		bool localip = 2;
		bool remoteip = 3;
		bool remotemx = 4;
		bool recipientdomain = 5;
		bool jobid = 6;
		bool grouping = 7;
		bool tenantid = 8;
	}
	Fields policygroupings = 26;
}

message QueueUpdateRequest {
	message MailAddress {
		StringValue localpart = 1;
		StringValue domain = 2;
	}
	Condition conditions = 1;
	message Move {
		oneof Destination {
			Queue queue = 1;
			Freeze freeze = 2;
		}
		TimeValue retryts = 3;
		UInt64Value retrytsjitter = 4;
	}
	message Action {
		ActionType type = 1;
		message DSNStatus {
			uint64 class = 1;
			uint64 subject = 2;
			uint64 detail = 3;
		}
		message DSN {
			DSNStatus status = 1;
			string diagnosticcode = 2;
		}
		DSN dsn = 2;
	}
	oneof task {
		Move move = 2;
		ActionType actiontype = 3;
		Action action = 11;
	}
	StringValue transportid = 4;
	map<string, string> metadata = 5;
	bool freeze = 6;
	bool duplicate = 7;
	MailAddress sender = 8;
	MailAddress recipient = 9;
	UInt64Value retrycount = 10;
	UInt64Value priority = 12;
	message Paging {
		uint64 limit = 1;
	}
	Paging paging = 13;
	StringValue jobid = 14;
	StringValue tenantid = 15;
	bool background = 16;
}

message QueueUpdateResponse {
	uint64 affected = 1;
	uint64 working = 2;
	StringValue id = 3;
}

message QueueUpdateStatusRequest {
	string id = 1;
}


message QueueUpdateStatusResponse {
	uint64 pending = 1;
	uint64 before = 2;
}

message Groupings {
	repeated StringRegexValue transportid = 1;
	repeated StringValue localip = 2;
	repeated StringValue remoteip = 3;
	repeated StringRegexValue remotemx = 4;
	repeated StringRegexValue recipientdomain = 5;
	repeated StringRegexValue jobid = 6;
	repeated StringRegexValue grouping = 7;
	repeated StringRegexValue tenantid = 8;
}

message QueueGroupByRequest {
	message Paging {
		uint64 offset = 1;
		uint64 limit = 2;
	}
	message GroupBy {
		oneof GroupUnique {
			bool transportid = 1;
			bool recipientdomain = 2;
			bool senderdomain = 3;
			bool jobid = 4;
			bool grouping = 10;
			bool tenantid = 11;
			string metadata = 5;
			bool senderip = 6;
			bool remoteip = 7;
			bool remotemx = 8;
			bool localip = 9;
		}
	}
	message Sorting {
		oneof SortingType {
			uint64 groupby = 1;
			bool total = 2;
			uint64 count = 3;
		}
		Order order = 4;
	}
	message QueueState {
		Queue queue = 1;
	}
	message FreezeState {
		Freeze freeze = 1;
	}
	message WorkingState {
		Working working = 1;
	}
	message Counts {
		oneof type {
			Queue queue = 1;
			Freeze freeze = 2;
			Working working = 3;
			CompareTime ts = 4;
			CompareTime retryts = 5;
			CompareUInt64 retrycount = 6;
			CompareUInt64 priority = 8;
			bool suspended = 9;
		}
		message ReturnType {
			message Unique {
				oneof unique {
					bool transportid = 1;
					bool recipientdomain = 2;
					bool senderdomain = 3;
					bool jobid = 4;
					bool grouping = 11;
					bool tenantid = 12;
					string metadata = 5;
					bool senderip = 6;
					bool remoteip = 7;
					bool remotemx = 8;
					bool localip = 9;
				}
				bool nogrouping = 10;
			}
			enum Type {
				COUNT = 0;
				BYTES = 1;
			}
			oneof ReturnType {
				Type type = 1;
				Unique unique = 2;
			}
		}
		ReturnType return = 7;
	}
	Condition conditions = 1;
	repeated Sorting sortings = 2;
	Paging paging = 3;
	repeated GroupBy groupbys = 4;
	repeated Counts counts = 5;
	enum ReturnType {
		COUNT = 0;
		BYTES = 1;
	}
	ReturnType return = 6;
	map<string, Groupings> groupings = 7;
	message Fields {
		bool transportid = 1;
		bool localip = 2;
		bool remoteip = 3;
		bool remotemx = 4;
		bool recipientdomain = 5;
		bool jobid = 6;
		bool grouping = 7;
		bool tenantid = 8;
	}
	Fields policygroupings = 8;
}

message QueueGroupByResponse {
	message Item {
		repeated string groupbys = 1;
		repeated uint64 counts = 2;
		uint64 total = 3;
	}
	repeated Item items = 1;
	message Total {
		repeated uint64 counts = 2;
		uint64 total = 3;
	}
	Total total = 3;
	message Paging {
		uint64 total = 1;
	}
	Paging paging = 2;
}

message QueueListRequest {
	message SortingMailAddress {
		oneof SortingMailAddress {
			Order localpart = 1;
			Order domain = 2;
		}
	}
	message SortingWorking {
		oneof SortingWorking {
			Order duration = 1;
		}
	}
	message Sorting {
		oneof Sorting {
			Order ts = 1;
			SortingMailAddress sender = 2;
			SortingMailAddress recipient = 3;
			SortingWorking working = 4;
			Order retryts = 5;
			Order size = 6;
			Order retrycount = 7;
		}
	}
	message Paging {
		uint64 offset = 1;
		uint64 limit = 2;
	}
	Condition conditions = 1;
	repeated Sorting sortings = 2;
	Paging paging = 3;
}

message QueueListResponse {
	message QueueItem {
		message MailAddress {
			string localpart = 1;
			string domain = 2;
		}
		message QueueState {
			Queue queue = 1;
		}
		message FreezeState {
			Freeze freeze = 1;
		}
		message WorkingState {
			Working working = 1;
			bool updatefreezing = 2;
			double duration = 3;
		}
		message DSN {
			string envid = 1;
			string ret = 2;
			string notify = 3;
			string orcpt = 4;
		};
		QueueItemID id = 1;
		oneof State {
			QueueState queue = 2;
			FreezeState freeze = 3;
			WorkingState working = 4;
		}
		string hqfpath = 5;
		double ts = 6;

		bool hold = 7;
		string jobid = 8;
		string grouping = 31;
		string tenantid = 32;
		string stageid = 9;
		map<string, string> metadata = 10;

		string serverid = 11;
		string transportid = 12;

		MailAddress sender = 13;
		MailAddress recipient = 14;

		uint64 retrycount = 15;
		double retrydelay = 16;
		string retryreason = 17;
		uint64 size = 18;

		string senderip = 19;
		string senderhelo = 20;
		string saslusername = 21;
		string subject = 22;

		repeated string localips = 23;
		bool localipsordered = 30;
		string remoteip = 24;
		string remotemx = 25;
		repeated string tags = 26;
		repeated string quotas = 27;
		DSN dsn = 28;
		uint64 priority = 29;
	}
	repeated QueueItem items = 1;
	message Paging {
		uint64 total = 1;
	}
	Paging paging = 2;
}

message QueueUnloadRequest {
	Condition conditions = 1;
	bool freeze = 2;
	bool partial = 3;
}

message QueueUnloadResponse {
	repeated string hqfpaths = 1;
	uint64 partial = 2;
	uint64 working = 3;
}

message QueueImportRequest {
	message ImportData {
		bytes rfc822 = 1;
		bytes hqf = 2;
	}
	message Reset {
		BoolValue transactionid = 1;
		BoolValue ts = 2;
		BoolValue retrycount = 3;
	}
	ImportData data = 1;
	Reset reset = 2;
}

message QueueImportResponse {
	string transactionid = 1;
}

message QueueExportRequest {
	QueueItemID id = 1;
}

message ConfigGreenConditions {
	repeated string remoteips = 1;
	repeated string serverids = 2;
	float probability = 3;
	uint64 time = 4;
	uint64 count = 5;
}

message ConfigGreenStatusResponse {
	string id = 1;
	bool expired = 2;
	uint64 time = 3;
	uint64 count = 4;
	ConfigGreenConditions conditions = 5;
}

message ConfigGreenDeployRequest {
	string id = 1;
	ConfigGreenConditions conditions = 2;
	string config = 3;
	bool connectionbound = 4;
}

message HSLCacheResponse {
	message Item {
		string namespace = 1;
		string function = 2;
		uint64 maxsize = 3;
		uint64 size = 4;
		uint64 hits = 5;
		uint64 misses = 6;
		uint64 evicts = 7;
		uint64 waits = 8;
	}
	repeated Item items = 1;
}

message HSLLogResponse {
	message Location {
		uint64 beginline = 1;
		uint64 endline = 2;
		uint64 begincolumn = 3;
		uint64 endcolumn = 4;
		string file = 5;
	}
	Location location = 1;
	bytes text = 2;
	string id = 3;
}

message HSLBreakPointResponse {
	message Location {
		uint64 beginline = 1;
		uint64 endline = 2;
		uint64 begincolumn = 3;
		uint64 endcolumn = 4;
		string file = 5;
	}
	message Callstack {
		string function = 1;
	}
	string id = 1;
	string debugid = 2;
	string transactionid = 3;
	Location location = 4;
	double time = 5;
	string values = 6;
	repeated Callstack callstack = 7;
}

message HSLCacheClearRequest {
	StringValue namespace = 1;
	StringValue function = 2;
	map<uint64, string> arguments = 3;
}

message HSLCacheClearResponse {
	uint64 affected = 1;
}

message HealthRequest {
	bool unhealthy = 1;
}

message ProcessStatsResponse {
	message Process {
		uint64 pid = 1;
		double runtime = 2;
		message Version {
			uint64 major = 1;
			uint64 minor = 2;
			uint64 patch = 3;
		}
		Version version = 3;
		message License {
			int64 expiration = 1;
		}
		License license = 4;
	}
	message Monitor {
		bool ready = 1;
		bool healthy = 2;
	}
	Monitor monitor = 7;
	message Connections {
		uint64 concurrent = 1;
		uint64 maxconcurrent = 2;
	}
	message Script {
		uint64 pending = 1;
		uint64 running = 2;
		uint64 finished = 3;
		uint64 errors = 4;
		uint64 threads = 5;
		uint64 suspended = 6;
		string threadid = 7;
	}
	message Scripts {
		Script connect = 1;
		Script proxy = 2;
		Script helo = 3;
		Script auth = 4;
		Script mailfrom = 5;
		Script rcptto = 6;
		Script eod = 7;
		Script disconnect = 8;
	}
	message ServerCounters {
		string serverid = 1;
		Connections connections = 2;
		Scripts scripts = 3;
	}
	message Resolver {
		message Cache {
			uint64 maxsize = 7;
			uint64 size = 1;
			uint64 hits = 2;
			uint64 misses = 3;
			uint64 expires = 4;
			uint64 evicts = 5;
			uint64 skips = 6;
		}
		uint64 pending = 1;
		uint64 dedup = 5;
		uint64 running = 2;
		uint64 maxrunning = 4;
		Cache cache = 3;
		message Domain {
			message Cache {
				uint64 maxsize = 1;
				uint64 size = 2;
				uint64 hits = 3;
				uint64 misses = 4;
				uint64 expires = 5;
				uint64 evicts = 6;
			}
			Cache cache = 1;
		}
		Domain domain = 6;
		uint64 queries = 7;
		message Servers {
			string server = 1;
			uint64 threadid = 2;
			uint64 queries = 3;
			uint64 errors = 4;
			uint64 tcp = 5;
		}
		repeated Servers servers = 8;
	}
	message Queue {
		message Script {
			uint64 pending = 1;
			uint64 running = 2;
			uint64 finished = 3;
			uint64 errors = 4;
			uint64 threads = 5;
			uint64 suspended = 6;
			string threadid = 7;
		}
		message Scripts {
			Script predelivery = 1;
			Script postdelivery = 2;
		}
		message Loader {
			uint64 count = 1;
			uint64 pending = 2;
			uint64 active = 3;
			uint64 maxactive = 4;
		}
		message Queue {
			message Defer {
				uint64 size = 1;
			}
			message Active {
				uint64 size = 1;
				message Priority {
					uint64 size = 1;
				}
				repeated Priority priorities = 2;
			}
			Defer defer = 1;
			Active active = 2;
		}
		message Freeze {
			message Hold {
				uint64 size = 1;
			}
			message Update {
				uint64 size = 1;
				uint64 pending = 2;
			}
			Hold hold = 1;
			Update update = 2;
		}
		message Policy {
			message Concurrency {
				uint64 counters = 1;
				uint64 suspends = 2;
			}
			message Rate {
				uint64 buckets = 1;
				uint64 suspends = 2;
			}
			message Dynamic {
				uint64 suspends = 1;
				uint64 conditions = 2;
			}
			message Connectinterval {
				uint64 buckets = 1;
				uint64 suspends = 2;
			}
			Concurrency concurrency = 1;
			Rate rate = 2;
			Dynamic dynamic = 3;
			Connectinterval connectinterval = 4;
		}
		message Pooling {
			uint64 size = 1;
			uint64 maxsize = 7;
			uint64 hits = 2;
			uint64 misses = 3;
			uint64 expires = 4;
			uint64 evicts = 5;
			uint64 skips = 6;
		}
		message Connections {
			uint64 concurrent = 1;
			uint64 maxconcurrent = 3;
			Pooling pooling = 2;
		}
		message Pickup {
			uint64 count = 3;
			uint64 skips = 1;
			uint64 misses = 2;
			uint64 pending = 4;
			uint64 evals = 5;
			uint64 putback = 6;
			uint64 requeue = 7;
			bool backpressured = 8;
		}
		message Quota {
			uint64 size = 1;
		}
		message Delivery {
			uint64 delivered = 1;
			uint64 delayed = 2;
			uint64 failed = 3;
		}
		message Release {
			uint64 pending = 1;
		}
		message Update {
			message Background {
				uint64 pending = 1;
			}
			Background background = 1;
		}
		Loader loader = 1;
		Scripts scripts = 2;
		Queue queue = 3;
		Freeze freeze = 4;
		Policy policy = 5;
		Pickup pickup = 6;
		Connections connections = 7;
		Quota quota = 8;
		Delivery delivery = 9;
		Release release = 10;
		Update update = 11;
	}
	message Threads {
		message Scripts {
			string id = 1;
			uint64 pending = 2;
			uint64 rescheduled = 3;
			uint64 running = 4;
			uint64 maxrunning = 5;
			uint64 scripts = 6;
			uint64 maxscripts = 7;
			uint64 finished = 8;
		}
		repeated Scripts scripts = 1;
	}
	message Cluster {
		bool connected = 1;
		uint64 hosts = 2;
	}
	message Config {
		uint64 active = 1;
		uint64 reloads = 2;
	}
	Process process = 1;
	Resolver resolver = 2;
	repeated ServerCounters servers = 3;
	Queue queue = 4;
	Threads threads = 5;
	Cluster cluster = 6;
	Config config = 8;
}

message QueueQuotaRequest {
	string quota = 1;
}

message QueueQuotaResponse {
	uint64 count = 1;
	uint64 bytes = 2;
}

message HSLMemoryRequest {
	string key = 1;
}

message HSLMemoryResponse {
	string value = 1;
}

message HSLMemoryListRequest {
	message Condition {
		StringMatch key = 1;
	}
	message Paging {
		uint64 offset = 1;
		uint64 limit = 2;
	}
	Condition condition = 1;
	Paging paging = 2;
}

message HSLMemoryListResponse {
	repeated string keys = 1;
}

message HSLMemoryStoreRequest {
	string key = 1;
	string value = 2;
	bool return = 3;
}

message HSLMemoryStoreResponse {
	string value = 1;
}

message HSLMemoryDeleteRequest {
	string key = 1;
	bool return = 2;
}

message HSLMemoryDeleteResponse {
	uint64 affected = 1;
	string value = 2;
}

message SuspendCondition {
	enum Source {
		STATIC = 0;
		CONCURRENCY = 1;
		RATE = 2;
		DYNAMIC = 3;
		CONNECTINTERVAL = 4;
	}
	StringValue transportid = 1;
	repeated string localips = 2;
	StringValue remoteip = 3;
	StringValue remotemx = 4;
	StringValue recipientdomain = 5;
	StringValue jobid = 6;
	StringValue grouping = 9;
	StringValue tenantid = 10;
	StringMatch tag = 7;
	bool pickup = 8;
	repeated Source sources = 11;
}

message SuspendRequest {
	oneof filter {
		string id = 1;
		SuspendCondition condition = 2;
	}
	message Paging {
		uint64 limit = 1;
	}
	Paging paging = 4;
}

message SuspendResponse {
	enum Source {
		STATIC = 0;
		CONCURRENCY = 1;
		RATE = 2;
		DYNAMIC = 3;
		CONNECTINTERVAL = 4;
	}
	message Item {
		Source source = 1;
		string id = 2;
		StringValue transportid = 3;
		StringValue localip = 4;
		StringValue remoteip = 5;
		StringValue remotemx = 6;
		StringValue recipientdomain = 7;
		StringValue jobid = 8;
		StringValue grouping = 11;
		StringValue tenantid = 12;
		double ttl = 9;
		StringValue tag = 10;
		map<string, string> properties = 13;
	}
	repeated Item items = 1;
}

message SuspendAddRequest {
	string id = 9;
	StringValue transportid = 1;
	StringValue localip = 2;
	StringValue remoteip = 3;
	StringValue remotemx = 4;
	StringValue recipientdomain = 5;
	StringValue jobid = 6;
	StringValue grouping = 10;
	StringValue tenantid = 11;
	double ttl = 7;
	StringValue tag = 8;
	map<string, string> properties = 12;
}

message SuspendAddResponse {
	string id = 1;
}

message SuspendUpdateRequest {
	string id = 9;
	double ttl = 7;
	StringValue tag = 8;
	map<string, string> properties = 12;
}

message SuspendUpdateResponse {
	uint64 affected = 1;
}

message SuspendDeleteRequest {
	oneof filter {
		string id = 1;
		SuspendCondition condition = 2;
	}
}

message SuspendDeleteResponse {
	uint64 affected = 1;
}

enum PolicyConditionRateAlgorithm {
	DEFAULT = 0;
	TOKENBUCKET = 1;
	FIXEDWINDOW = 2;
}

message PolicyConditionAddRequest {
	message Fields {
		bool transportid = 1;
		bool localip = 2;
		bool remoteip = 3;
		bool remotemx = 4;
		bool recipientdomain = 5;
		bool jobid = 6;
		bool grouping = 7;
		bool tenantid = 8;
	}
	message If {
		StringValue transportid = 1;
		StringValue localip = 2;
		StringValue remoteip = 3;
		StringValue remotemx = 4;
		StringValue recipientdomain = 5;
		StringValue jobid = 6;
		StringValue grouping = 7;
		StringValue tenantid = 8;
	}
	message Then {
		message Rate {
			uint64 count = 1;
			double interval = 2;
			PolicyConditionRateAlgorithm algorithm = 3;
		}
		Rate rate = 1;
		uint64 concurrency = 2;
		StringValue tag = 3;
		bool stop = 4;
		map<string, string> properties = 5;
		double connectinterval = 6;
		BoolValue cluster = 7;
	}
	string id = 5;
	Fields fields = 1;
	If if = 2;
	Then then = 3;
	double ttl = 4;
	enum Type {
		DYNAMIC = 0;
		BACKOFF = 1;
		WARMUP = 2;
	}
	Type type = 6;
}

message PolicyConditionAddResponse {
	string id = 1;
}

message PolicyConditionUpdateRequest {
	message Then {
		message Rate {
			uint64 count = 1;
			double interval = 2;
			PolicyConditionRateAlgorithm algorithm = 3;
		}
		Rate rate = 1;
		uint64 concurrency = 2;
		StringValue tag = 3;
		bool stop = 4;
		map<string, string> properties = 5;
		double connectinterval = 6;
		BoolValue cluster = 7;
	}
	string id = 1;
	Then then = 2;
	double ttl = 3;
}

message PolicyConditionUpdateResponse {
	uint64 affected = 1;
}

message PolicyConditionDeleteRequest {
	oneof filter {
		string id = 1;
		PolicyConditionCondition condition = 2;
	}
}

message PolicyConditionDeleteResponse {
	uint64 affected = 1;
}

message PolicyConditionCondition {
	enum Source {
		DYNAMIC = 0;
		CLUSTER = 1;
		BACKOFF = 2;
		WARMUP = 3;
		STATIC = 4;
	}
	StringValue transportid = 1;
	repeated string localips = 2;
	StringValue remoteip = 3;
	StringValue remotemx = 4;
	StringValue recipientdomain = 5;
	StringValue jobid = 6;
	StringValue grouping = 9;
	StringValue tenantid = 10;
	StringMatch tag = 7;
	repeated Source sources = 11;
}

message PolicyConditionRequest {
	oneof filter {
		string id = 1;
		PolicyConditionCondition condition = 2;
	}
	message Paging {
		uint64 limit = 1;
		uint64 offset = 2;
	}
	Paging paging = 4;
}

message PolicyConditionResponse {
	enum Source {
		DYNAMIC = 0;
		CLUSTER = 1;
		BACKOFF = 2;
		WARMUP = 3;
		STATIC = 4;
	}
	message Item {
		message Fields {
			bool transportid = 1;
			bool localip = 2;
			bool remoteip = 3;
			bool remotemx = 4;
			bool recipientdomain = 5;
			bool jobid = 6;
			bool grouping = 7;
			bool tenantid = 8;
		}
		message If {
			repeated StringValue transportid = 1;
			repeated StringValue localip = 2;
			repeated StringValue remoteip = 3;
			repeated StringValue remotemx = 4;
			repeated StringValue recipientdomain = 5;
			repeated StringValue jobid = 6;
			repeated StringValue grouping = 7;
			repeated StringValue tenantid = 8;
		}
		message Then {
			message Rate {
				uint64 count = 1;
				double interval = 2;
				PolicyConditionRateAlgorithm algorithm = 3;
			}
			Rate rate = 1;
			uint64 concurrency = 2;
			StringValue tag = 3;
			bool stop = 4;
			map<string, string> properties = 5;
			double connectinterval = 6;
			bool cluster = 7;
		}
		string id = 1;
		Fields fields = 2;
		If if = 3;
		Then then = 4;
		double ttl = 5;
		Source source = 6;
	}
	repeated Item items = 1;
}

message PolicyRateRefillRequest {
	StringValue transportid = 1;
	StringValue localip = 2;
	StringValue remoteip = 3;
	StringValue remotemx = 4;
	StringValue recipientdomain = 5;
	StringValue jobid = 6;
	StringValue grouping = 8;
	StringValue tenantid = 9;
	double tokens = 7;
}

message PolicyRateRefillResponse {
	uint64 affected = 1;
}

message PluginCommandRequest {
	string id = 1;
	repeated bytes arguments = 2;
}

message PluginCommandResponse {
	bytes response = 1;
}

message ServerConnectionsListRequest {
	message Condition {
		string connectionid = 1;
		string remoteip = 2;
		string serverid = 3;
		string localip = 4;
		UInt64Value priority = 5;
	}
	message Paging {
		uint64 offset = 1;
		uint64 limit = 2;
	}
	Condition condition = 1;
	Paging paging = 2;
}

message ServerConnectionsListResponse {
	message Connection {
		string connectionid = 1;
		string remoteip = 2;
		uint32 remoteport = 7;
		string remoteptr = 3;
		string localip = 8;
		uint32 localport = 9;
		string serverid = 4;
		double duration = 5;
		uint64 transactions = 6;
		uint64 priority = 10;
	}
	repeated Connection connections = 1;
}

message ServerConnectionsCloseRequest {
	message Reply {
		uint64 code = 1;
		string reason = 2;
	}
	Reply reply = 1;
	string connectionid = 2;
	string remoteip = 3;
	string serverid = 4;
	string localip = 5;
	UInt64Value priority = 6;
}

message ServerConnectionsCloseResponse {
	uint64 affected = 1;
}

message QueueConnectionsListRequest {
	message Condition {
		string connectionid = 1;
		string grouping = 7;
		string localip = 2;
		string remoteip = 3;
		string remotemx = 6;
		string proxyip = 4;
		QueueItemID id = 5;
		string state = 8;
		bool active = 9;
	}
	message Paging {
		uint64 offset = 1;
		uint64 limit = 2;
	}
	Condition condition = 1;
	Paging paging = 2;
}

message QueueConnectionsListResponse {
	message Connection {
		string connectionid = 1;
		string grouping = 13;
		string localip = 2;
		uint32 localport = 3;
		string remoteip = 4;
		uint32 remoteport = 5;
		string remotemx = 12;
		string proxyip = 6;
		double duration = 7;
		uint64 transactions = 8;
		string state = 9;
		double stateduration = 10;
		QueueItemID id = 11;
	}
	repeated Connection connections = 1;
}

message QueueConnectionsCloseRequest {
	string connectionid = 1;
	string grouping = 7;
	string localip = 2;
	string remoteip = 3;
	string remotemx = 6;
	string proxyip = 4;
	QueueItemID id = 5;
	string state = 8;
	bool active = 9;
}

message QueueConnectionsCloseResponse {
	uint64 affected = 1;
}

message PolicyMatchRequest {
	string transportid = 1;
	string localip = 2;
	string remoteip = 3;
	string remotemx = 4;
	string recipientdomain = 5;
	string jobid = 6;
	string grouping = 7;
	string tenantid = 8;
}

message PolicyMatchResponse {
	message PolicyMatch {
		message Fields {
			bool transportid = 1;
			bool localip = 2;
			bool remoteip = 3;
			bool remotemx = 4;
			bool recipientdomain = 5;
			bool jobid = 6;
			bool grouping = 7;
			bool tenantid = 8;
		}
		Fields fields = 1;
		message Grouping {
			StringValue transportid = 1;
			StringValue localip = 2;
			StringValue remoteip = 3;
			StringValue remotemx = 4;
			StringValue recipientdomain = 5;
			StringValue jobid = 6;
			StringValue grouping = 7;
			StringValue tenantid = 8;
		}
		Grouping grouping = 2;
		message Dynamic {
			string id = 1;
			StringValue tag = 2;
		}
		repeated Dynamic dynamic = 3;
		repeated string tags = 4;
		UInt64Value concurrency = 5;
		UInt64Value concurrencyeffective = 11;
		message Rate {
			uint64 count = 1;
			double interval = 2;
			PolicyConditionRateAlgorithm algorithm = 3;
		}
		Rate rate = 6;
		Rate rateeffective = 12;
		map<string, string> properties = 7;
		DoubleValue connectinterval = 9;
		DoubleValue connectintervaleffective = 13;
		bool stop = 8;
	}
	repeated PolicyMatch policies = 1;
	double duration = 2;
}

message PolicyGroupingListRequest {
	message Paging {
		uint64 offset = 1;
		uint64 limit = 2;
	}
	Paging paging = 1;
}

message PolicyGroupingListResponse {
	message Grouping {
		message Fields {
			bool transportid = 1;
			bool localip = 2;
			bool remoteip = 3;
			bool remotemx = 4;
			bool recipientdomain = 5;
			bool jobid = 6;
			bool grouping = 7;
			bool tenantid = 8;
		}
		Fields fields = 1;
		oneof field {
			string transportid = 2;
			string localip = 3;
			string remoteip = 4;
			string remotemx = 5;
			string recipientdomain = 6;
			string jobid = 7;
			string grouping = 8;
			string tenantid = 9;
		}
	}
	repeated Grouping groupings = 1;
}

message PolicyGroupingRequest {
	message Fields {
		bool transportid = 1;
		bool localip = 2;
		bool remoteip = 3;
		bool remotemx = 4;
		bool recipientdomain = 5;
		bool jobid = 6;
		bool grouping = 7;
		bool tenantid = 8;
	}
	Fields fields = 1;
	oneof field {
		string transportid = 2;
		string localip = 3;
		string remoteip = 4;
		string remotemx = 5;
		string recipientdomain = 6;
		string jobid = 7;
		string grouping = 8;
		string tenantid = 9;
	}
}

message PolicyGroupingResponse {
	repeated string items = 1;
}

message ResolverCacheClearRequest {
	StringValue domain = 1;
}

message ResolverCacheClearResponse {
	uint64 affected = 1;
}

message TraceSMTPRequest {
	StringValue transportid = 1;
	StringValue localip = 2;
	StringValue remoteip = 3;
	StringValue remotemx = 4;
	StringValue recipientdomain = 5;
	StringValue jobid = 6;
	StringValue grouping = 10;
	StringValue tenantid = 13;
	bool connect = 7;
	bool hexdump = 8;
	bool nopipelining = 9;
	enum TimeStampType {
		ABSOLUTE = 0;
		ELAPSED = 1;
		AGGREGATED = 2;
	}
	TimeStampType ts = 11;
	QueueItemID id = 12;
}

message ConfigResponse {
	message Transport {
		string id = 1;
	}
	message Grouping {
		string id = 1;
	}
	message LocalIP {
		string id = 1;
		string address = 2;
	}
	message PolicyField {
		bool transportid = 1;
		bool localip = 2;
		bool remoteip = 3;
		bool remotemx = 4;
		bool recipientdomain = 5;
		bool jobid = 6;
		bool grouping = 7;
		bool tenantid = 8;
	}
	message List {
		message ListItem {
			string id = 1;
		}
		repeated ListItem transportids = 1;
		repeated ListItem localips = 2;
		repeated ListItem remoteips = 3;
		repeated ListItem remotemxs = 4;
		repeated ListItem recipientdomains = 5;
		repeated ListItem jobids = 6;
		repeated ListItem groupings = 7;
		repeated ListItem tenantids = 8;
	}
	repeated Transport transports = 1;
	repeated Grouping groupings = 2;
	repeated LocalIP localips = 3;
	repeated PolicyField policyfields = 4;
	enum PoolingPolicyType {
		REMOTE = 0;
		REMOTEMX = 1;
		GROUPING = 2;
	}
	PoolingPolicyType poolingpolicy = 5;
	bool cluster = 6;
	List lists = 7;
}

message ResolverQueryListRequest {

}

message ResolverQueryListResponse {
	message Item {
		string hostname = 1;
		double duration = 2;
	}
	repeated Item items = 1;
}

message ResolverQueueListRequest {
	message Paging {
		uint64 offset = 1;
		uint64 limit = 2;
	}
	Paging paging = 1;
	StringValue hostname = 2;
	UInt64Value dedup = 3;
}

message ResolverQueueListResponse {
	message Item {
		uint64 position = 1;
		string hostname = 2;
		uint64 priority = 3;
		uint64 dedup = 4;
	}
	repeated Item items = 1;
}

message QueueAnalyzeRequest {

}

message QueueAnalyzeResponse {
	message Bucket {
		uint64 total = 1;
		uint64 unique = 2;
	}
	message Tree {
		Bucket prio = 1;
		Bucket tenantid = 2;
		Bucket jobid = 3;
		Bucket transportid = 4;
		Bucket localip = 5;
		Bucket grouping = 6;
		Bucket remoteip = 7;
		Bucket remotemx = 8;
		Bucket recipientdomain = 9;
	}
	Tree tree = 1;
}
