diff --git a/raystack/frontier/v1beta1/frontier.proto b/raystack/frontier/v1beta1/frontier.proto index eab89d9b..80f1516f 100644 --- a/raystack/frontier/v1beta1/frontier.proto +++ b/raystack/frontier/v1beta1/frontier.proto @@ -1362,6 +1362,482 @@ service FrontierService { description: "List a user preferences by ID."; }; } + + // Billing account + rpc CreateBillingAccount(CreateBillingAccountRequest) returns (CreateBillingAccountResponse) { + option (google.api.http) = { + post: "/v1beta1/billing", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Billing"; + summary: "Create billing account"; + description: "Create a new billing account for an organization."; + }; + } + + rpc GetBillingAccount(GetBillingAccountRequest) returns (GetBillingAccountResponse) { + option (google.api.http) = {get: "/v1beta1/billing/{id}"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Billing"; + summary: "Get billing account"; + description: "Get a billing account by ID."; + }; + } + + rpc UpdateBillingAccount(UpdateBillingAccountRequest) returns (UpdateBillingAccountResponse) { + option (google.api.http) = { + put: "/v1beta1/billing/{id}", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Billing"; + summary: "Update billing account"; + description: "Update a billing account by ID."; + }; + } + + rpc ListBillingAccounts(ListBillingAccountsRequest) returns (ListBillingAccountsResponse) { + option (google.api.http) = {get: "/v1beta1/billing"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Billing"; + summary: "List billing accounts"; + description: "List billing accounts of an organization."; + }; + } + + rpc DeleteBillingAccount(DeleteBillingAccountRequest) returns (DeleteBillingAccountResponse) { + option (google.api.http) = {delete: "/v1beta1/billing/{id}"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Billing"; + summary: "Delete billing account"; + description: "Delete a billing account by ID."; + }; + } + + rpc GetBillingBalance(GetBillingBalanceRequest) returns (GetBillingBalanceResponse) { + option (google.api.http) = {get: "/v1beta1/billing/{id}/balance"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Billing"; + summary: "Get billing balance"; + description: "Get the balance of a billing account by ID."; + }; + } + + // Subscriptions + rpc GetSubscription(GetSubscriptionRequest) returns (GetSubscriptionResponse) { + option (google.api.http) = {get: "/v1beta1/billing/{billing_id}/subscriptions/{id}"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Subscription"; + summary: "Get subscription"; + description: "Get a subscription by ID."; + }; + } + + rpc ListSubscriptions(ListSubscriptionsRequest) returns (ListSubscriptionsResponse) { + option (google.api.http) = {get: "/v1beta1/billing/{billing_id}/subscriptions"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Subscription"; + summary: "List subscriptions"; + description: "List subscriptions of a billing account."; + }; + } + + rpc UpdateSubscription(UpdateSubscriptionRequest) returns (UpdateSubscriptionResponse) { + option (google.api.http) = { + put: "/v1beta1/billing/{billing_id}/subscriptions/{id}", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Subscription"; + summary: "Update subscription"; + description: "Update a subscription by ID."; + }; + } + + // Billing Feature + rpc CreateFeature(CreateFeatureRequest) returns (CreateFeatureResponse) { + option (google.api.http) = { + post: "/v1beta1/billing/features", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Feature"; + summary: "Create feature"; + description: "Create a new feature for platform."; + }; + } + + rpc GetFeature(GetFeatureRequest) returns (GetFeatureResponse) { + option (google.api.http) = {get: "/v1beta1/billing/features/{id}"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Feature"; + summary: "Get feature"; + description: "Get a feature by ID."; + }; + } + + rpc ListFeatures(ListFeaturesRequest) returns (ListFeaturesResponse) { + option (google.api.http) = {get: "/v1beta1/billing/features"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Feature"; + summary: "List features"; + description: "List all features of a platform."; + }; + } + + rpc UpdateFeature(UpdateFeatureRequest) returns (UpdateFeatureResponse) { + option (google.api.http) = { + put: "/v1beta1/billing/features/{id}", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Feature"; + summary: "Update feature"; + description: "Update a feature by ID."; + }; + } + + // Plans + rpc CreatePlan(CreatePlanRequest) returns (CreatePlanResponse) { + option (google.api.http) = { + post: "/v1beta1/billing/plans", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Plan"; + summary: "Create plan"; + description: "Create a new plan for platform."; + }; + } + + rpc ListPlans(ListPlansRequest) returns (ListPlansResponse) { + option (google.api.http) = {get: "/v1beta1/billing/plans"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Plan"; + summary: "List plans"; + description: "List all plans."; + }; + } + + rpc GetPlan(GetPlanRequest) returns (GetPlanResponse) { + option (google.api.http) = {get: "/v1beta1/billing/plans/{id}"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Plan"; + summary: "Get plan"; + description: "Get a plan by ID."; + }; + } + + rpc UpdatePlan(UpdatePlanRequest) returns (UpdatePlanResponse) { + option (google.api.http) = { + put: "/v1beta1/billing/plans/{id}", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Plan"; + summary: "Update plan"; + description: "Update a plan by ID."; + }; + } + + // Checkout + rpc CreateCheckout(CreateCheckoutRequest) returns (CreateCheckoutResponse) { + option (google.api.http) = { + post: "/v1beta1/billing/{billing_id}/checkouts", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Checkout"; + summary: "Checkout a feature or subscription"; + description: "Checkout a feature to buy it one time or start a subscription plan on a billing account."; + }; + } + + rpc ListCheckouts(ListCheckoutsRequest) returns (ListCheckoutsResponse) { + option (google.api.http) = {get: "/v1beta1/billing/{billing_id}/checkouts"}; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Checkout"; + summary: "List checkouts"; + description: "List all checkouts of a billing account."; + }; + } + + // Billing Entitlements + rpc CheckFeatureEntitlement(CheckFeatureEntitlementRequest) returns (CheckFeatureEntitlementResponse) { + option (google.api.http) = { + post: "/v1beta1/billing/{billing_id}/check", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "Entitlement"; + summary: "Check entitlement"; + description: "Check if a billing account is entitled to a feature."; + }; + } +} + +// Billing + +message BillingAccountRequestBody { + string name = 1; + string email = 2; + string phone = 3; + BillingAccount.Address address = 4; + string currency = 5; + + google.protobuf.Struct metadata = 10; +} + +message CreateBillingAccountRequest { + // ID of the organization to create the billing account for + string org_id = 1 [(validate.rules).string.min_len = 1]; + // Billing account to create. + BillingAccountRequestBody body = 2; +} + +message CreateBillingAccountResponse { + // Created billing account + BillingAccount billing_account = 1; +} + +message GetBillingAccountRequest { + // ID of the billing account to get + string id = 1 [(validate.rules).string.min_len = 1]; + + string org_id = 2 [(validate.rules).string.min_len = 1]; +} + +message GetBillingAccountResponse { + // Billing account + BillingAccount billing_account = 1; +} + +message UpdateBillingAccountRequest { + // ID of the billing account to update + string id = 1 [(validate.rules).string.min_len = 1]; + + string org_id = 2 [(validate.rules).string.min_len = 1]; + + // Billing account to update. + BillingAccountRequestBody body = 3; +} + +message UpdateBillingAccountResponse { + // Updated billing account + BillingAccount billing_account = 1; +} + +message ListBillingAccountsRequest { + // ID of the organization to list billing accounts for + string org_id = 1 [(validate.rules).string.min_len = 1]; +} + +message ListBillingAccountsResponse { + // List of billing accounts + repeated BillingAccount billing_accounts = 1; +} + +message DeleteBillingAccountRequest { + // ID of the billing account to delete + string id = 1 [(validate.rules).string.min_len = 1]; + + string org_id = 2 [(validate.rules).string.min_len = 1]; +} + +message DeleteBillingAccountResponse {} + +message GetBillingBalanceRequest { + // ID of the billing account to get the balance for + string id = 1 [(validate.rules).string.min_len = 1]; + + string org_id = 2 [(validate.rules).string.min_len = 1]; +} + +message GetBillingBalanceResponse { + // Balance of the billing account + BillingAccount.Balance balance = 1; +} + +message GetSubscriptionRequest { + // ID of the billing account to get the subscription for + string billing_id = 1 [(validate.rules).string.min_len = 1]; + // ID of the subscription to get + string id = 2 [(validate.rules).string.min_len = 1]; +} + +message GetSubscriptionResponse { + Subscription subscription = 1; +} + +message ListSubscriptionsRequest { + // ID of the billing account to list subscriptions for + string billing_id = 1 [(validate.rules).string.min_len = 1]; +} + +message ListSubscriptionsResponse { + // List of subscriptions + repeated Subscription subscriptions = 1; +} + +message UpdateSubscriptionRequest { + // ID of the billing account to update the subscription for + string billing_id = 1 [(validate.rules).string.min_len = 1]; + // ID of the subscription to update + string id = 2 [(validate.rules).string.min_len = 1]; + + google.protobuf.Struct metadata = 20; +} + +message UpdateSubscriptionResponse { + // Updated subscription + Subscription subscription = 1; +} + +message ListPlansRequest {} + +message ListPlansResponse { + // List of plans + repeated Plan plans = 1; +} + +message CheckFeatureEntitlementRequest { + string billing_id = 1 [(validate.rules).string.min_len = 1]; + string feature = 2 [(validate.rules).string.min_len = 1]; +} + +message CheckFeatureEntitlementResponse { + bool status = 1; +} + +message CheckoutSubscriptionBody { + string plan = 1; + int32 trail_days = 2; +} + +message CheckoutFeatureBody { + string feature = 1; +} + +message CreateCheckoutRequest { + // ID of the billing account to create the subscription for + string billing_id = 1 [(validate.rules).string.min_len = 1]; + + string success_url = 2; + string cancel_url = 3; + + // Subscription to create + CheckoutSubscriptionBody subscription_body = 10; + // Feature to buy + CheckoutFeatureBody feature_body = 11; +} + +message CreateCheckoutResponse { + // Checkout session + CheckoutSession checkout_session = 1; +} + +message ListCheckoutsRequest { + // ID of the billing account to list checkouts for + string billing_id = 1 [(validate.rules).string.min_len = 1]; +} + +message ListCheckoutsResponse { + // List of checkouts + repeated CheckoutSession checkout_sessions = 1; +} + +message FeatureRequestBody { + string name = 1; + string title = 2; + string description = 3; + string plan_id = 4; + + repeated Price prices = 5; + + google.protobuf.Struct metadata = 20; +} + +message CreateFeatureRequest { + // Feature to create + FeatureRequestBody body = 1; +} + +message CreateFeatureResponse { + // Created feature + Feature feature = 1; +} + +message GetFeatureRequest { + // ID of the feature to get + string id = 1 [(validate.rules).string.min_len = 1]; +} + +message GetFeatureResponse { + // Feature + Feature feature = 1; +} + +message ListFeaturesRequest {} + +message ListFeaturesResponse { + // List of features + repeated Feature features = 1; +} + +message UpdateFeatureRequest { + // ID of the feature to update + string id = 1 [(validate.rules).string.min_len = 1]; + // Feature to update + FeatureRequestBody body = 2; +} + +message UpdateFeatureResponse { + // Updated feature + Feature feature = 1; +} + +message PlanRequestBody { + string name = 1; + string title = 2; + string description = 3; + + repeated Feature features = 4; + string interval = 5; // known intervals are "day", "week", "month", and "year" + + google.protobuf.Struct metadata = 20; +} + +message CreatePlanRequest { + // Plan to create + PlanRequestBody body = 1; +} + +message CreatePlanResponse { + // Created plan + Plan plan = 1; +} + +message GetPlanRequest { + // ID of the plan to get + string id = 1 [(validate.rules).string.min_len = 1]; +} + +message GetPlanResponse { + // Plan + Plan plan = 1; +} + +message UpdatePlanRequest { + // ID of the plan to update + string id = 1 [(validate.rules).string.min_len = 1]; + // Plan to update + PlanRequestBody body = 2; +} + +message UpdatePlanResponse { + // Updated plan + Plan plan = 1; } // Authentication diff --git a/raystack/frontier/v1beta1/models.proto b/raystack/frontier/v1beta1/models.proto index 12e8d262..5070b84a 100644 --- a/raystack/frontier/v1beta1/models.proto +++ b/raystack/frontier/v1beta1/models.proto @@ -531,6 +531,115 @@ message Preference { }]; } +message BillingAccount { + message Address { + string line1 = 1; + string line2 = 2; + string city = 3; + string state = 4; + string postal_code = 5; + string country = 6; + } + + message Balance { + int64 amount = 1; + string currency = 2; + + google.protobuf.Timestamp updated_at = 3; + } + + string id = 1; + string org_id = 2; + + string name = 3; + string email = 4; + string phone = 5; + Address address = 6; + string provider_id = 7; + string provider = 8; + string currency = 9; + string state = 10; + + google.protobuf.Struct metadata = 20; + google.protobuf.Timestamp created_at = 21; + google.protobuf.Timestamp updated_at = 22; +} + +message Subscription { + string id = 1; + string customer_id = 2; + string provider_id = 3; + string plan_id = 4; + + string state = 5; + int32 trial_days = 9; + + google.protobuf.Struct metadata = 10; + google.protobuf.Timestamp created_at = 11; + google.protobuf.Timestamp updated_at = 12; + google.protobuf.Timestamp canceled_at = 13; +} + +message CheckoutSession { + string id = 1; + + string checkout_url = 2; + string success_url = 3; + string cancel_url = 4; + string state = 5; + + google.protobuf.Struct metadata = 10; + google.protobuf.Timestamp created_at = 11; + google.protobuf.Timestamp updated_at = 12; + google.protobuf.Timestamp expire_at = 13; +} + +message Plan { + string id = 1; + string name = 2; + string title = 3; + string description = 4; + repeated Feature features = 5; + string interval = 6; // known intervals are "day", "week", "month", and "year" + + google.protobuf.Struct metadata = 20; + google.protobuf.Timestamp created_at = 21; + google.protobuf.Timestamp updated_at = 22; +} + +message Feature { + string id = 1; + string name = 2; + string title = 3; + string description = 4; + repeated string plan_ids = 5; + string state = 6; + + repeated Price prices = 7; + + google.protobuf.Struct metadata = 20; + google.protobuf.Timestamp created_at = 21; + google.protobuf.Timestamp updated_at = 22; +} + +message Price { + string id = 1; + string feature_id = 2; + string provider_id = 3; + string name = 4; + string usage_type = 7; // known types are "licensed" and "metered" + string billing_scheme = 8; // known schemes are "tiered" and "flat" + string state = 9; + string currency = 10; // like "usd", "eur", "gbp" + int64 amount = 11; + string metered_aggregate = 13; // known aggregations are "sum", "last_during_period" and "max" + string tier_mode = 14; // known modes are "graduated" and "volume" + + google.protobuf.Struct metadata = 20; + google.protobuf.Timestamp created_at = 21; + google.protobuf.Timestamp updated_at = 22; +} + // Model crud body message RoleRequestBody {