2022-09-08 12:37:23 +02:00

122 lines
3.1 KiB
Protocol Buffer

syntax = "proto3";
package usage.v1;
option go_package = "github.com/gitpod-io/gitpod/usage-api/v1";
import "google/protobuf/timestamp.proto";
service UsageService {
// GetCostCenter retrieves the spending limit with its associated attributionID
rpc GetCostCenter(GetCostCenterRequest) returns (GetCostCenterResponse) {}
// Triggers reconciliation of usage with ledger implementation.
rpc ReconcileUsageWithLedger(ReconcileUsageWithLedgerRequest) returns (ReconcileUsageWithLedgerResponse) {}
// ListUsage retrieves all usage for the specified attributionId and theb given time range
rpc ListUsage(ListUsageRequest) returns (ListUsageResponse) {}
}
message ReconcileUsageWithLedgerRequest {
// from specifies the starting time range for this request.
google.protobuf.Timestamp from = 1;
// to specifies the end time range for this request.
google.protobuf.Timestamp to = 2;
}
message ReconcileUsageWithLedgerResponse {}
message PaginatedRequest {
int64 per_page = 1;
int64 page = 2;
}
message PaginatedResponse {
int64 per_page = 2;
int64 total_pages = 3;
int64 total = 4;
int64 page = 5;
}
message ListUsageRequest {
string attribution_id = 1;
// from specifies the starting time range for this request.
// All instances which existed starting at from will be returned.
google.protobuf.Timestamp from = 2;
// to specifies the end time range for this request.
// All instances which existed ending at to will be returned.
google.protobuf.Timestamp to = 3;
enum Ordering {
ORDERING_DESCENDING = 0;
ORDERING_ASCENDING = 1;
}
Ordering order = 4;
PaginatedRequest pagination = 5;
}
message ListUsageResponse {
repeated Usage usage_entries = 1;
PaginatedResponse pagination = 2;
// the amount of credits the given account (attributionId) had at the beginning of the requested period
double credit_balance_at_start = 3;
// the amount of credits the given account (attributionId) had at the end of the requested period
double credit_balance_at_end = 4;
}
message Usage {
string id = 1;
string attribution_id = 2;
string description = 3;
double credits = 4;
google.protobuf.Timestamp effective_time = 5;
enum Kind {
KIND_WORKSPACE_INSTANCE = 0;
KIND_INVOICE = 1;
}
Kind kind = 6;
string workspace_instance_id = 7;
bool draft = 8;
string metadata = 9;
}
message BilledSession {
string attribution_id = 1;
string user_id = 2;
string team_id = 3;
string workspace_id = 4;
string workspace_type = 5;
string project_id = 6;
string instance_id = 7;
string workspace_class = 8;
google.protobuf.Timestamp start_time = 9;
google.protobuf.Timestamp end_time = 10;
int64 credits_deprecated = 11 [deprecated=true]; // insufficient precision to represent credits for workspace time
double credits = 12;
}
message GetCostCenterRequest {
string attribution_id = 1;
}
message GetCostCenterResponse {
CostCenter cost_center = 1;
}
message CostCenter {
string attribution_id = 1;
int32 spending_limit = 2;
}