syntax = "proto3";

import "proto/api_key.proto";
import "proto/bazel_config.proto";
import "proto/eventlog.proto";
import "proto/execution_stats.proto";
import "proto/grp.proto";
import "proto/invocation.proto";
import "proto/runner.proto";
import "proto/target.proto";
import "proto/user.proto";
import "proto/workflow.proto";
import "proto/scheduler.proto";
import "proto/usage.proto";

package buildbuddy.service;

option go_package = "buildbuddy_service";

service BuildBuddyService {
  // Invocation API
  rpc GetInvocation(invocation.GetInvocationRequest)
      returns (invocation.GetInvocationResponse);
  rpc SearchInvocation(invocation.SearchInvocationRequest)
      returns (invocation.SearchInvocationResponse);
  rpc GetInvocationStat(invocation.GetInvocationStatRequest)
      returns (invocation.GetInvocationStatResponse);
  rpc UpdateInvocation(invocation.UpdateInvocationRequest)
      returns (invocation.UpdateInvocationResponse);
  rpc DeleteInvocation(invocation.DeleteInvocationRequest)
      returns (invocation.DeleteInvocationResponse);
  rpc GetTrend(invocation.GetTrendRequest)
      returns (invocation.GetTrendResponse);
  rpc GetInvocationOwner(invocation.GetInvocationOwnerRequest)
      returns (invocation.GetInvocationOwnerResponse);

  // Bazel Config API
  rpc GetBazelConfig(bazel_config.GetBazelConfigRequest)
      returns (bazel_config.GetBazelConfigResponse);

  // User API
  rpc CreateUser(user.CreateUserRequest) returns (user.CreateUserResponse);
  rpc GetUser(user.GetUserRequest) returns (user.GetUserResponse);
  rpc GetImpersonatedUser(user.GetUserRequest) returns (user.GetUserResponse);

  // Groups API
  rpc GetGroup(grp.GetGroupRequest) returns (grp.GetGroupResponse);
  rpc GetGroupUsers(grp.GetGroupUsersRequest)
      returns (grp.GetGroupUsersResponse);
  rpc UpdateGroupUsers(grp.UpdateGroupUsersRequest)
      returns (grp.UpdateGroupUsersResponse);
  rpc JoinGroup(grp.JoinGroupRequest) returns (grp.JoinGroupResponse);
  rpc CreateGroup(grp.CreateGroupRequest) returns (grp.CreateGroupResponse);
  rpc UpdateGroup(grp.UpdateGroupRequest) returns (grp.UpdateGroupResponse);

  // API Keys API
  rpc GetApiKeys(api_key.GetApiKeysRequest)
      returns (api_key.GetApiKeysResponse);
  rpc CreateApiKey(api_key.CreateApiKeyRequest)
      returns (api_key.CreateApiKeyResponse);
  rpc UpdateApiKey(api_key.UpdateApiKeyRequest)
      returns (api_key.UpdateApiKeyResponse);
  rpc DeleteApiKey(api_key.DeleteApiKeyRequest)
      returns (api_key.DeleteApiKeyResponse);

  // Execution API
  rpc GetExecution(execution_stats.GetExecutionRequest)
      returns (execution_stats.GetExecutionResponse);
  rpc GetExecutionNodes(scheduler.GetExecutionNodesRequest)
      returns (scheduler.GetExecutionNodesResponse);

  // Target API
  rpc GetTarget(target.GetTargetRequest) returns (target.GetTargetResponse);

  // Workflow API
  rpc CreateWorkflow(workflow.CreateWorkflowRequest)
      returns (workflow.CreateWorkflowResponse);
  rpc DeleteWorkflow(workflow.DeleteWorkflowRequest)
      returns (workflow.DeleteWorkflowResponse);
  rpc GetWorkflows(workflow.GetWorkflowsRequest)
      returns (workflow.GetWorkflowsResponse);
  rpc ExecuteWorkflow(workflow.ExecuteWorkflowRequest)
      returns (workflow.ExecuteWorkflowResponse);
  rpc GetRepos(workflow.GetReposRequest) returns (workflow.GetReposResponse);

  // Runner API
  rpc Run(runner.RunRequest) returns (runner.RunResponse);

  // Eventlog API
  rpc GetEventLogChunk(eventlog.GetEventLogChunkRequest)
      returns (eventlog.GetEventLogChunkResponse);

  // Usage API
  rpc GetUsage(usage.GetUsageRequest) returns (usage.GetUsageResponse);
}
