syntax = "proto3";

option go_package = "github.com/openziti/zrok/agent/agentGrpc";

import "google/api/annotations.proto";

service Agent {
	rpc AccessPrivate(AccessPrivateRequest) returns (AccessPrivateResponse) {
		option(google.api.http) = {
			post: "/v1/agent/accessPrivate"
		};
	}
	rpc ReleaseAccess(ReleaseAccessRequest) returns (ReleaseAccessResponse) {
		option(google.api.http) = {
			post: "/v1/agent/releaseAccess"
		};
	}
	rpc ReleaseShare(ReleaseShareRequest) returns (ReleaseShareResponse) {
		option(google.api.http) = {
			post: "/v1/agent/releaseShare"
		};
	}
	rpc ShareReserved(ShareReservedRequest) returns (ShareReservedResponse) {}
	rpc SharePrivate(SharePrivateRequest) returns (SharePrivateResponse) {
		option(google.api.http) = {
			post: "/v1/agent/sharePrivate"
		};
	}
	rpc SharePublic(SharePublicRequest) returns (SharePublicResponse) {
		option(google.api.http) = {
			post: "/v1/agent/sharePublic"
		};
	}
	rpc Status(StatusRequest) returns (StatusResponse) {
		option(google.api.http) = {
			get: "/v1/agent/status"
		};
	}
	rpc Version(VersionRequest) returns (VersionResponse) {
		option(google.api.http) = {
			get: "/v1/agent/version"
		};
	}
}

message AccessDetail {
	string frontendToken = 1;
	string token = 2;
	string bindAddress = 3;
	repeated string responseHeaders = 4;
}

message AccessPrivateResponse{
	string frontendToken = 1;
}

message AccessPrivateRequest{
	string token = 1;
	string bindAddress = 2;
	bool autoMode = 3;
	string autoAddress = 4;
	uint32 autoStartPort = 5;
	uint32 autoEndPort = 6;
	repeated string responseHeaders = 7;
}

message ReleaseAccessRequest {
	string frontendToken = 1;
}

message ReleaseAccessResponse {
}

message ReleaseShareRequest {
	string token = 1;
}

message ReleaseShareResponse {
}

message ShareDetail {
	string token = 1;
	string shareMode = 2;
	string backendMode = 3;
	bool reserved = 4;
	repeated string frontendEndpoint = 5;
	string backendEndpoint = 6;
	bool closed = 7;
	string status = 8;
}

message SharePrivateRequest {
	string target = 1;
	string backendMode = 2;
	bool insecure = 3;
	bool closed = 4;
	repeated string accessGrants = 5;
}

message SharePrivateResponse {
	string token = 1;
}

message SharePublicRequest {
	string target = 1;
	repeated string basicAuth = 2;
	repeated string frontendSelection = 3;
	string backendMode = 4;
	bool insecure = 5;
	string oauthProvider = 6;
	repeated string oauthEmailAddressPatterns = 7;
	string oauthCheckInterval = 8;
	bool closed = 9;
	repeated string accessGrants = 10;
}

message SharePublicResponse {
	string token = 1;
	repeated string frontendEndpoints = 2;
}

message ShareReservedRequest {
	string token = 1;
	string overrideEndpoint = 2;
	bool insecure = 3;
}

message ShareReservedResponse {
	string token = 1;
	string backendMode = 2;
	string shareMode = 3;
	repeated string frontendEndpoints = 4;
	string target = 5;
}

message StatusRequest {
}

message StatusResponse {
	repeated AccessDetail accesses = 1;
	repeated ShareDetail shares = 2;
}

message VersionRequest {
}

message VersionResponse {
	string v = 1;
	string consoleEndpoint = 2;
}
