syntax = "proto3";

option go_package = ".;api";

package api;

service Registry {
	rpc ListPackages(ListPackageRequest) returns (stream PackageName) {}
	rpc GetPackage(GetPackageRequest) returns (Package) {}
	rpc GetBundle(GetBundleRequest) returns (Bundle) {}
	rpc GetBundleForChannel(GetBundleInChannelRequest) returns (Bundle) {}
	rpc GetChannelEntriesThatReplace(GetAllReplacementsRequest) returns (stream ChannelEntry) {}
	rpc GetBundleThatReplaces(GetReplacementRequest) returns (Bundle) {}
	rpc GetChannelEntriesThatProvide(GetAllProvidersRequest) returns (stream ChannelEntry) {}
	rpc GetLatestChannelEntriesThatProvide(GetLatestProvidersRequest) returns (stream ChannelEntry) {}
	rpc GetDefaultBundleThatProvides(GetDefaultProviderRequest) returns (Bundle) {}
	rpc ListBundles(ListBundlesRequest) returns (stream Bundle) {}
}

message Channel{
	string name = 1;
	string csvName = 2;
}

message PackageName{
	string name = 1;
}

message Package{
	string name = 1;
	repeated Channel channels = 2;
	string defaultChannelName = 3;
}

message GroupVersionKind{
	string group = 1;
	string version = 2;
	string kind = 3;
	string plural = 4;
}

message Dependency{
  string type = 1;
  string value = 2;
}

message Property{
  string type = 1;
  string value = 2;
}

message Bundle{
	string csvName = 1;
	string packageName = 2;
	string channelName = 3;
	string csvJson = 4;
	repeated string object = 5;
	string bundlePath = 6;
	repeated GroupVersionKind providedApis = 7;
	repeated GroupVersionKind requiredApis = 8;
	string version = 9;
	string skipRange = 10;
	repeated Dependency dependencies = 11;
	repeated Property properties = 12;
	string replaces = 13;
	repeated string skips = 14;
}

message ChannelEntry{
	string packageName = 1;
	string channelName = 2;
	string bundleName = 3;
	string replaces = 4;
}

message ListPackageRequest{}

message ListBundlesRequest{}

message GetPackageRequest{
	string name = 1;
}

message GetBundleRequest{
	string pkgName = 1;
	string channelName = 2;
	string csvName = 3;
}

message GetBundleInChannelRequest{
	string pkgName = 1;
	string channelName = 2;
}

message GetAllReplacementsRequest{
	string csvName = 1;
}

message GetReplacementRequest{
	string csvName = 1;
	string pkgName = 2;
	string channelName = 3;
}

message GetAllProvidersRequest{
	string group = 1;
	string version = 2;
	string kind = 3;
	string plural = 4;
}

message GetLatestProvidersRequest{
	string group = 1;
	string version = 2;
	string kind = 3;
	string plural = 4;
}

message GetDefaultProviderRequest{
	string group = 1;
	string version = 2;
	string kind = 3;
	string plural = 4;
}
