84 lines
2.3 KiB
Protocol Buffer

syntax = "proto3";
package usage.v1;
option go_package = "github.com/gitpod-io/gitpod/usage-api/v1";
import "google/protobuf/timestamp.proto";
import "usage/v1/usage.proto";
service BillingService {
// UpdateInvoices takes provides BilledSessions and reflects their usage
// in a billing system.
// This is an Internal RPC used by the usage reconciler and not intended for general consumption.
rpc UpdateInvoices(UpdateInvoicesRequest) returns (UpdateInvoicesResponse) {};
// ReconcileInvoices retrieves current credit balance and reflects it in billing system.
// Internal RPC, not intended for general consumption.
rpc ReconcileInvoices(ReconcileInvoicesRequest) returns (ReconcileInvoicesResponse) {};
// GetUpcomingInvoice retrieves the latest invoice for a given query.
rpc GetUpcomingInvoice(GetUpcomingInvoiceRequest) returns (GetUpcomingInvoiceResponse) {};
// FinalizeInvoice marks all sessions occurring in the given Stripe invoice as
// having been invoiced.
rpc FinalizeInvoice(FinalizeInvoiceRequest) returns (FinalizeInvoiceResponse) {};
// SetBilledSession marks an instance as billed with a billing system
rpc SetBilledSession(SetBilledSessionRequest) returns (SetBilledSessionResponse) {};
}
message UpdateInvoicesRequest {
google.protobuf.Timestamp start_time = 1;
google.protobuf.Timestamp end_time = 2;
repeated BilledSession sessions = 3 [deprecated=true];
// report_id is a unique identifier of the usage report for this UpdateInvoicesRequest
string report_id = 4;
}
message UpdateInvoicesResponse {
}
message ReconcileInvoicesRequest {}
message ReconcileInvoicesResponse {}
message GetUpcomingInvoiceRequest {
oneof identifier {
string team_id = 1;
string user_id = 2;
}
}
message GetUpcomingInvoiceResponse {
string invoice_id = 1;
string currency = 2;
double amount = 3;
int64 credits = 4;
}
message FinalizeInvoiceRequest {
string invoice_id = 1;
}
message FinalizeInvoiceResponse {
}
enum System {
SYSTEM_UNKNOWN = 0;
SYSTEM_CHARGEBEE = 1;
SYSTEM_STRIPE = 2;
}
// If there are two billable sessions for this instance ID,
// the second one's "from" will be the first one's "to"
message SetBilledSessionRequest {
string instance_id = 1;
google.protobuf.Timestamp from = 2;
System system = 3;
}
message SetBilledSessionResponse {
}