diff --git a/raystack/frontier/v1beta1/admin.proto b/raystack/frontier/v1beta1/admin.proto index a14abfbb..b23c83a0 100644 --- a/raystack/frontier/v1beta1/admin.proto +++ b/raystack/frontier/v1beta1/admin.proto @@ -336,6 +336,23 @@ service AdminService { description: "Lists all the billing accounts from all the organizations in a Frontier instance. It can be filtered by organization."; }; } + + // Usage + rpc RevertBillingUsage(RevertBillingUsageRequest) returns (RevertBillingUsageResponse) { + option (google.api.http) = { + post: "/v1beta1/admin/organizations/{org_id}/billing/{billing_id}/usage/{usage_id}/revert", + body: "*" + additional_bindings { + post: "/v1beta1/organizations/billing/usages/revert", + body: "*" + } + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Billing"; + summary: "Revert billing usage"; + description: "Revert billing usage for a billing account."; + }; + } } message ListAllUsersRequest { @@ -574,3 +591,24 @@ message ListAllBillingAccountsRequest { message ListAllBillingAccountsResponse { repeated BillingAccount billing_accounts = 1; } + +message RevertBillingUsageRequest { + // either provide org_id or infer org from project_id + string org_id = 1; + string project_id = 2; + + // either provide billing_id of the org or API can infer the default + // billing ID from either org_id or project_id, not both + string billing_id = 3 [(validate.rules).string = { + ignore_empty: true, + uuid: true + }]; + + // usage id to revert, a usage can only be allowed to revert once + string usage_id = 4 [(validate.rules).string = {uuid: true}]; + + // amount should be equal or less than the usage amount + int64 amount = 5 [(validate.rules).int64 = {gte: 0}]; +} + +message RevertBillingUsageResponse {} diff --git a/raystack/frontier/v1beta1/models.proto b/raystack/frontier/v1beta1/models.proto index 2f13ac8d..e3446080 100644 --- a/raystack/frontier/v1beta1/models.proto +++ b/raystack/frontier/v1beta1/models.proto @@ -625,8 +625,8 @@ message Plan { "year" ] }]; - int64 on_start_credits = 7; - int64 trial_days = 8; + int64 on_start_credits = 7 [(validate.rules).int64 = {gte: 0}]; + int64 trial_days = 8 [(validate.rules).int64 = {gte: 0}]; google.protobuf.Struct metadata = 20; google.protobuf.Timestamp created_at = 21; @@ -714,7 +714,7 @@ message Price { string state = 9; // currency like "usd", "eur", "gbp" string currency = 10; - int64 amount = 11; + int64 amount = 11 [(validate.rules).int64 = {gte: 0}]; // metered_aggregate known aggregations are "sum", "last_during_period" and "max" string metered_aggregate = 13 [(validate.rules).string = { ignore_empty: true, @@ -743,7 +743,7 @@ message BillingTransaction { string customer_id = 2; // additional metadata for storing event/service that triggered this usage string source = 3; - int64 amount = 4; + int64 amount = 4 [(validate.rules).int64 = {gte: 0}]; string type = 5 [(validate.rules).string = { ignore_empty: true, in: [ @@ -779,7 +779,7 @@ message Usage { "feature" ] }]; - int64 amount = 6; + int64 amount = 6 [(validate.rules).int64 = {gte: 0}]; // user_id is the user that triggered this usage string user_id = 7;