syntax = "proto3";

package containerd.services.snapshots.v1;

import "gogoproto/gogo.proto";
import "google/protobuf/empty.proto";
import "github.com/containerd/containerd/api/types/mount.proto";

option go_package = "github.com/containerd/containerd/api/services/snapshot/v1;snapshot";

// Snapshot service manages snapshots
service Snapshots {
	rpc Prepare(PrepareSnapshotRequest) returns (PrepareSnapshotResponse);
	rpc View(ViewSnapshotRequest) returns (ViewSnapshotResponse);
	rpc Mounts(MountsRequest) returns (MountsResponse);
	rpc Commit(CommitSnapshotRequest) returns (google.protobuf.Empty);
	rpc Remove(RemoveSnapshotRequest) returns (google.protobuf.Empty);
	rpc Stat(StatSnapshotRequest) returns (StatSnapshotResponse);
	rpc List(ListSnapshotsRequest) returns (stream ListSnapshotsResponse);
	rpc Usage(UsageRequest) returns (UsageResponse);
}

message PrepareSnapshotRequest {
	string snapshotter = 1;
	string key = 2;
	string parent = 3;
}

message PrepareSnapshotResponse {
	repeated containerd.types.Mount mounts = 1;
}

message ViewSnapshotRequest {
	string snapshotter = 1;
	string key = 2;
	string parent = 3;
}

message ViewSnapshotResponse {
	repeated containerd.types.Mount mounts = 1;
}

message MountsRequest {
	string snapshotter = 1;
	string key = 2;
}

message MountsResponse {
	repeated containerd.types.Mount mounts = 1;
}

message RemoveSnapshotRequest {
	string snapshotter = 1;
	string key = 2;
}

message CommitSnapshotRequest {
	string snapshotter = 1;
	string name = 2;
	string key = 3;
}

message StatSnapshotRequest {
	string snapshotter = 1;
	string key = 2;
}

enum Kind {
	option (gogoproto.goproto_enum_prefix) = false;
	option (gogoproto.enum_customname) = "Kind";

	UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "KindUnknown"];
	VIEW = 1 [(gogoproto.enumvalue_customname) = "KindView"];
	ACTIVE = 2 [(gogoproto.enumvalue_customname) = "KindActive"];
	COMMITTED = 3 [(gogoproto.enumvalue_customname) = "KindCommitted"];
}

message Info {
	string name = 1;
	string parent = 2;
	Kind kind = 3;
}

message StatSnapshotResponse {
	Info info = 1 [(gogoproto.nullable) = false];
}

message ListSnapshotsRequest{
	string snapshotter = 1;
}

message ListSnapshotsResponse {
	repeated Info info = 1 [(gogoproto.nullable) = false];
}

message UsageRequest {
	string snapshotter = 1;
	string key = 2;
}

message UsageResponse {
	int64 size = 1;
	int64 inodes = 2;
}
