syntax = "proto3";

package golem.component.v1;

import "golem/common/empty.proto";
import "golem/common/account_id.proto";
import "golem/component/v1/component_error.proto";
import "golem/component/plugin_definition.proto";

service PluginService {
  rpc ListPlugins (ListPluginsRequest) returns (ListPluginsResponse);
  rpc CreatePlugin (CreatePluginRequest) returns (CreatePluginResponse);
  rpc GetPlugin (GetPluginRequest) returns (GetPluginResponse);
  rpc DeletePlugin (DeletePluginRequest) returns (DeletePluginResponse);
  rpc GetPluginById (GetPluginByIdRequest) returns (GetPluginByIdResponse);
}

message ListPluginsRequest {
  golem.component.PluginScope scope = 1;
}

message ListPluginsResponse {
  oneof result {
    ListPluginsSuccessResponse success = 1;
    golem.component.v1.ComponentError error = 2;
  }
}

message ListPluginsSuccessResponse {
  repeated golem.component.PluginDefinition plugins = 1;
}

message CreatePluginRequest {
  golem.component.PluginDefinitionCreation plugin = 1;
}

message CreatePluginResponse {
  oneof result {
    golem.common.Empty success = 1;
    golem.component.v1.ComponentError error = 2;
  }
}

message GetPluginRequest {
  golem.common.AccountId account_id = 1;
  string name = 2;
  string version = 3;
}

message GetPluginResponse {
  oneof result {
    GetPluginSuccessResponse success = 1;
    golem.component.v1.ComponentError error = 2;
  }
}

message GetPluginSuccessResponse {
  golem.component.PluginDefinition plugin = 1;
}

message GetPluginByIdRequest {
  golem.component.PluginId id = 1;
}

message GetPluginByIdResponse {
  oneof result {
    GetPluginSuccessResponse success = 1;
    golem.component.v1.ComponentError error = 2;
  }
}

message DeletePluginRequest {
  golem.common.AccountId account_id = 1;
  string name = 2;
  string version = 3;
}

message DeletePluginResponse {
  oneof result {
    golem.common.Empty success = 1;
    golem.component.v1.ComponentError error = 2;
  }
}
