Files
backrest/proto/v1/service.proto
2024-05-27 10:26:18 -07:00

142 lines
3.7 KiB
Protocol Buffer

syntax = "proto3";
package v1;
option go_package = "github.com/garethgeorge/backrest/gen/go/v1";
import "v1/config.proto";
import "v1/restic.proto";
import "v1/operations.proto";
import "types/value.proto";
import "google/protobuf/empty.proto";
import "google/api/annotations.proto";
service Backrest {
rpc GetConfig (google.protobuf.Empty) returns (Config) {}
rpc SetConfig (Config) returns (Config) {}
rpc AddRepo (Repo) returns (Config) {}
rpc GetOperationEvents (google.protobuf.Empty) returns (stream OperationEvent) {}
rpc GetOperations (GetOperationsRequest) returns (OperationList) {}
rpc ListSnapshots(ListSnapshotsRequest) returns (ResticSnapshotList) {}
rpc ListSnapshotFiles(ListSnapshotFilesRequest) returns (ListSnapshotFilesResponse) {}
// Backup schedules a backup operation. It accepts a plan id and returns empty if the task is enqueued.
rpc Backup(types.StringValue) returns (google.protobuf.Empty) {}
// DoRepoTask schedules a repo task. It accepts a repo id and a task type and returns empty if the task is enqueued.
rpc DoRepoTask(DoRepoTaskRequest) returns (google.protobuf.Empty) {}
// Forget schedules a forget operation. It accepts a plan id and returns empty if the task is enqueued.
rpc Forget(ForgetRequest) returns (google.protobuf.Empty) {}
// Restore schedules a restore operation.
rpc Restore(RestoreSnapshotRequest) returns (google.protobuf.Empty) {}
// Cancel attempts to cancel a task with the given operation ID. Not guaranteed to succeed.
rpc Cancel(types.Int64Value) returns (google.protobuf.Empty) {}
// GetLogs returns the keyed large data for the given operation.
rpc GetLogs(LogDataRequest) returns (types.BytesValue) {}
// RunCommand executes a generic restic command on the repository.
rpc RunCommand(RunCommandRequest) returns (stream types.BytesValue) {}
// GetDownloadURL returns a signed download URL given a forget operation ID.
rpc GetDownloadURL(types.Int64Value) returns (types.StringValue) {}
// Clears the history of operations
rpc ClearHistory(ClearHistoryRequest) returns (google.protobuf.Empty) {}
// PathAutocomplete provides path autocompletion options for a given filesystem path.
rpc PathAutocomplete (types.StringValue) returns (types.StringList) {}
}
// OpSelector is a message that can be used to select operations e.g. by query.
message OpSelector {
repeated int64 ids = 1;
string repo_id = 2;
string plan_id = 3;
string snapshot_id = 4;
int64 flow_id = 5;
}
message DoRepoTaskRequest {
string repo_id = 1;
enum Task {
TASK_NONE = 0;
TASK_INDEX_SNAPSHOTS = 1;
TASK_PRUNE = 2;
TASK_CHECK = 3;
TASK_STATS = 4;
TASK_UNLOCK = 5;
}
Task task = 2;
}
message ClearHistoryRequest {
OpSelector selector = 1;
bool only_failed = 2;
}
message ForgetRequest {
string repo_id = 1;
string plan_id = 2;
string snapshot_id = 3;
}
message ListSnapshotsRequest {
string repo_id = 1;
string plan_id = 2;
}
message GetOperationsRequest {
OpSelector selector = 1;
int64 last_n = 2; // limit to the last n operations
}
message RestoreSnapshotRequest {
string plan_id = 1;
string repo_id = 5;
string snapshot_id = 2;
string path = 3;
string target = 4;
}
message ListSnapshotFilesRequest {
string repo_id = 1;
string snapshot_id = 2;
string path = 3;
}
message ListSnapshotFilesResponse {
string path = 1;
repeated LsEntry entries = 2;
}
message LogDataRequest {
string ref = 1;
}
message LsEntry {
string name = 1;
string type = 2;
string path = 3;
int64 uid = 4;
int64 gid = 5;
int64 size = 6;
int64 mode = 7;
string mtime = 8;
string atime = 9;
string ctime = 10;
}
message RunCommandRequest {
string repo_id = 1;
string command = 2;
}