syntax = "proto3"; package usage.v1; option go_package = "github.com/gitpod-io/gitpod/usage-api/v1"; import "google/protobuf/timestamp.proto"; service BillingService { // 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 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 { }