Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: introduce subscription v1 api (#5229)

ecmadao58a88f03ecee
diff --git a/backend/api/auth/config.go b/backend/api/auth/config.go
index 1238fc8b59..247c7c0687 100644
--- a/backend/api/auth/config.go
+++ b/backend/api/auth/config.go
@@ -2,6 +2,7 @@ package auth
var authenticationAllowlistMethods = map[string]bool{
"/bytebase.v1.ActuatorService/GetActuatorInfo": true,
+ "/bytebase.v1.SubscriptionService/GetSubscription": true,
"/bytebase.v1.AuthService/Login": true,
"/bytebase.v1.AuthService/Logout": true,
"/bytebase.v1.AuthService/CreateUser": true,
diff --git a/backend/api/v1/acl_config.go b/backend/api/v1/acl_config.go
index 608bb4efdf..40aeaa6c9e 100644
--- a/backend/api/v1/acl_config.go
+++ b/backend/api/v1/acl_config.go
@@ -22,12 +22,14 @@ var ownerAndDBAMethods = map[string]bool{
"InstanceService/AddDataSource": true,
"InstanceService/RemoveDataSource": true,
"InstanceService/UpdateDataSource": true,
+ "SubscriptionService/TrialSubscription": true,
}
var projectOwnerMethods = map[string]bool{
- "ProjectService/UpdateProject": true,
- "ProjectService/DeleteProject": true,
- "ProjectService/UndeleteProject": true,
+ "ProjectService/UpdateProject": true,
+ "ProjectService/DeleteProject": true,
+ "ProjectService/UndeleteProject": true,
+ "SubscriptionService/UpdateSubscription": true,
}
var transferDatabaseMethods = map[string]bool{
diff --git a/backend/api/v1/subscription_service.go b/backend/api/v1/subscription_service.go
new file mode 100644
index 0000000000..416826b532
--- /dev/null
+++ b/backend/api/v1/subscription_service.go
@@ -0,0 +1,203 @@
+package v1
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "time"
+
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
+ "google.golang.org/protobuf/types/known/timestamppb"
+
+ "github.com/bytebase/bytebase/backend/common"
+ "github.com/bytebase/bytebase/backend/component/config"
+ enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"
+ api "github.com/bytebase/bytebase/backend/legacyapi"
+ metricAPI "github.com/bytebase/bytebase/backend/metric"
+ "github.com/bytebase/bytebase/backend/plugin/metric"
+ "github.com/bytebase/bytebase/backend/runner/metricreport"
+ "github.com/bytebase/bytebase/backend/store"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
+)
+
+// SubscriptionService implements the subscription service.
+type SubscriptionService struct {
+ v1pb.UnimplementedSubscriptionServiceServer
+ workspaceID string
+ store *store.Store
+ profile *config.Profile
+ metricReporter *metricreport.Reporter
+ licenseService enterpriseAPI.LicenseService
+}
+
+// NewSubscriptionService creates a new SubscriptionService.
+func NewSubscriptionService(
+ workspaceID string,
+ store *store.Store,
+ profile *config.Profile,
+ metricReporter *metricreport.Reporter,
+ licenseService enterpriseAPI.LicenseService) *SubscriptionService {
+ return &SubscriptionService{
+ workspaceID: workspaceID,
+ store: store,
+ profile: profile,
+ metricReporter: metricReporter,
+ licenseService: licenseService,
+ }
+}
+
+// GetSubscription gets the subscription.
+func (s *SubscriptionService) GetSubscription(ctx context.Context, _ *v1pb.GetSubscriptionRequest) (*v1pb.Subscription, error) {
+ return s.loadSubscription(ctx)
+}
+
+// UpdateSubscription updates the subscription license.
+func (s *SubscriptionService) UpdateSubscription(ctx context.Context, request *v1pb.UpdateSubscriptionRequest) (*v1pb.Subscription, error) {
+ // clear the trialing setting for dev test
+ if request.Patch.License == "" && s.profile.Mode == common.ReleaseModeDev {
+ if err := s.store.DeleteSettingV2(ctx, api.SettingEnterpriseTrial); err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to delete the trialing license: %v", err.Error())
+ }
+ }
+
+ if err := s.licenseService.StoreLicense(ctx, &enterpriseAPI.SubscriptionPatch{
+ UpdaterID: ctx.Value(common.PrincipalIDContextKey).(int),
+ License: request.Patch.License,
+ }); err != nil {
+ if common.ErrorCode(err) == common.Invalid {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+ return nil, status.Errorf(codes.Internal, "failed to store license: %v", err.Error())
+ }
+
+ return s.loadSubscription(ctx)
+}
+
+// TrialSubscription creates a trial subscription.
+func (s *SubscriptionService) TrialSubscription(ctx context.Context, request *v1pb.TrialSubscriptionRequest) (*v1pb.Subscription, error) {
+ planType := api.FREE
+ switch request.Trial.Plan {
+ case v1pb.PlanType_TEAM:
+ planType = api.TEAM
+ case v1pb.PlanType_ENTERPRISE:
+ planType = api.ENTERPRISE
+ }
+
+ license := &enterpriseAPI.License{
+ InstanceCount: int(request.Trial.InstanceCount),
+ Seat: int(request.Trial.Seat),
+ ExpiresTs: time.Now().AddDate(0, 0, int(request.Trial.Days)).Unix(),
+ IssuedTs: time.Now().Unix(),
+ Plan: planType,
+ // the subject format for license should be {org id in hub}.{subscription id in hub}
+ // as we just need to simply generate the trialing license in console, we can use the workspace id instead.
+ Subject: fmt.Sprintf("%s.%s", s.workspaceID, ""),
+ Trialing: true,
+ OrgName: s.workspaceID,
+ }
+
+ subscription := s.licenseService.LoadSubscription(ctx)
+ basePlan := subscription.Plan
+
+ if license.Plan.Priority() <= subscription.Plan.Priority() {
+ return s.loadSubscription(ctx)
+ }
+
+ if subscription.Trialing {
+ license.ExpiresTs = subscription.ExpiresTs
+ license.IssuedTs = subscription.StartedTs
+ }
+
+ value, err := json.Marshal(license)
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+
+ principalID := ctx.Value(common.PrincipalIDContextKey).(int)
+ settingName := api.SettingEnterpriseTrial
+ settings, err := s.store.FindSetting(ctx, &api.SettingFind{
+ Name: &settingName,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to list settings: %v", err.Error())
+ }
+
+ if len(settings) == 0 {
+ // We will create a new setting named SettingEnterpriseTrial to store the free trial license.
+ _, created, err := s.store.CreateSettingIfNotExistV2(ctx, &store.SettingMessage{
+ Name: api.SettingEnterpriseTrial,
+ Value: string(value),
+ Description: "The trialing license.",
+ }, principalID)
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to create license: %v", err.Error())
+ }
+
+ if created && subscription.Trialing {
+ // For trial upgrade
+ // Case 1: Users just have the SettingEnterpriseTrial, don't upload their license in SettingEnterpriseLicense.
+ // Case 2: Users have the SettingEnterpriseLicense with team plan and trialing status.
+ // In both cases, we can override the SettingEnterpriseLicense with an empty value to get the valid free trial.
+ if err := s.licenseService.StoreLicense(ctx, &enterpriseAPI.SubscriptionPatch{
+ UpdaterID: principalID,
+ License: "",
+ }); err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to remove license: %v", err.Error())
+ }
+ }
+ } else {
+ // Update the existed free trial.
+ if _, err := s.store.PatchSetting(ctx, &api.SettingPatch{
+ UpdaterID: principalID,
+ Name: api.SettingEnterpriseTrial,
+ Value: string(value),
+ }); err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to patch license: %v", err.Error())
+ }
+ }
+
+ s.licenseService.RefreshCache(ctx)
+ subscription = s.licenseService.LoadSubscription(ctx)
+ currentPlan := subscription.Plan
+ s.metricReporter.Report(&metric.Metric{
+ Name: metricAPI.SubscriptionTrialMetricName,
+ Value: 1,
+ Labels: map[string]interface{}{
+ "trial_plan": currentPlan.String(),
+ "from_plan": basePlan.String(),
+ "lark_notified": false,
+ },
+ })
+
+ return s.loadSubscription(ctx)
+}
+
+func (s *SubscriptionService) loadSubscription(ctx context.Context) (*v1pb.Subscription, error) {
+ sub := s.licenseService.LoadSubscription(ctx)
+
+ plan := v1pb.PlanType_PLAN_TYPE_UNSPECIFIED
+ switch sub.Plan {
+ case api.FREE:
+ plan = v1pb.PlanType_FREE
+ case api.TEAM:
+ plan = v1pb.PlanType_TEAM
+ case api.ENTERPRISE:
+ plan = v1pb.PlanType_ENTERPRISE
+ }
+
+ subscription := &v1pb.Subscription{
+ Seat: int32(sub.Seat),
+ InstanceCount: int32(sub.InstanceCount),
+ Plan: plan,
+ Trialing: sub.Trialing,
+ OrgId: sub.OrgID,
+ OrgName: sub.OrgName,
+ }
+ if sub.Plan != api.FREE {
+ subscription.ExpiresTime = timestamppb.New(time.Unix(sub.ExpiresTs, 0))
+ subscription.StartedTime = timestamppb.New(time.Unix(sub.StartedTs, 0))
+ }
+
+ return subscription, nil
+}
diff --git a/backend/legacyapi/plan.go b/backend/legacyapi/plan.go
index b2739a2bff..3bfc5cc197 100644
--- a/backend/legacyapi/plan.go
+++ b/backend/legacyapi/plan.go
@@ -290,24 +290,6 @@ var FeatureMatrix = map[FeatureType][3]bool{
FeaturePluginOpenAI: {false, false, true},
}
-// Plan is the API message for a plan.
-type Plan struct {
- Type PlanType `jsonapi:"attr,type"`
-}
-
-// PlanPatch is the API message for patching a plan.
-type PlanPatch struct {
- Type PlanType `jsonapi:"attr,type"`
-}
-
-// TrialPlanCreate is the API message for creating a trial plan.
-type TrialPlanCreate struct {
- Type PlanType `jsonapi:"attr,type"`
- Days int `jsonapi:"attr,days"`
- Seat int `jsonapi:"attr,seat"`
- InstanceCount int `jsonapi:"attr,instanceCount"`
-}
-
// PlanLimit is the type for plan limits.
type PlanLimit int
diff --git a/backend/server/acl.go b/backend/server/acl.go
index dcc711cf4c..6a8eb38bec 100644
--- a/backend/server/acl.go
+++ b/backend/server/acl.go
@@ -286,10 +286,6 @@ func aclMiddleware(s *Server, pathPrefix string, ce *casbin.Enforcer, next echo.
}
method := c.Request().Method
- // Skip GET /subscription request
- if common.HasPrefixes(path, "/subscription") && method == "GET" {
- return next(c)
- }
// Skip GET /feature request
if common.HasPrefixes(path, "/feature") && method == "GET" {
diff --git a/backend/server/acl_casbin_policy_dba.csv b/backend/server/acl_casbin_policy_dba.csv
index ecc6fb97db..2aaa46155b 100644
--- a/backend/server/acl_casbin_policy_dba.csv
+++ b/backend/server/acl_casbin_policy_dba.csv
@@ -102,8 +102,6 @@ p, DBA, /setting, GET
p, DBA, /label, GET
p, DBA, /label/{labelID}, PATCH
p, DBA, /feature, GET
-p, DBA, /subscription, GET
-p, DBA, /subscription/trial, POST
p, DBA, /sheet, POST
p, DBA, /sheet/my, GET
p, DBA, /sheet/shared, GET
diff --git a/backend/server/acl_casbin_policy_developer.csv b/backend/server/acl_casbin_policy_developer.csv
index c68a727594..03bf1459b2 100644
--- a/backend/server/acl_casbin_policy_developer.csv
+++ b/backend/server/acl_casbin_policy_developer.csv
@@ -86,7 +86,6 @@ p, DEVELOPER, /vcs/{vcsID}/external-repository, GET
p, DEVELOPER, /setting, GET
p, DEVELOPER, /label, GET
p, DEVELOPER, /feature, GET
-p, DEVELOPER, /subscription, GET
p, DEVELOPER, /sheet, POST
p, DEVELOPER, /sheet/my, GET
p, DEVELOPER, /sheet/shared, GET
diff --git a/backend/server/acl_casbin_policy_owner.csv b/backend/server/acl_casbin_policy_owner.csv
index 72d3679163..bd843bd130 100644
--- a/backend/server/acl_casbin_policy_owner.csv
+++ b/backend/server/acl_casbin_policy_owner.csv
@@ -110,9 +110,6 @@ p, OWNER, /setting/{name}, PATCH
p, OWNER, /label, GET
p, OWNER, /label/{labelID}, PATCH
p, OWNER, /feature, GET
-p, OWNER, /subscription, GET
-p, OWNER, /subscription, PATCH
-p, OWNER, /subscription/trial, POST
p, OWNER, /sheet, POST
p, OWNER, /sheet/my, GET
p, OWNER, /sheet/shared, GET
diff --git a/backend/server/jwt.go b/backend/server/jwt.go
index 59e0f22b81..32719c402b 100644
--- a/backend/server/jwt.go
+++ b/backend/server/jwt.go
@@ -129,10 +129,6 @@ func JWTMiddleware(pathPrefix string, principalStore *store.Store, next echo.Han
}
method := c.Request().Method
- // Skip GET /subscription request
- if common.HasPrefixes(path, "/subscription") && method == "GET" {
- return next(c)
- }
// Skip GET /feature request
if common.HasPrefixes(path, "/feature") && method == "GET" {
diff --git a/backend/server/server.go b/backend/server/server.go
index 40c7117f1d..4abed557e4 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -508,7 +508,6 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
s.registerBookmarkRoutes(apiGroup)
s.registerSQLRoutes(apiGroup)
s.registerVCSRoutes(apiGroup)
- s.registerSubscriptionRoutes(apiGroup)
s.registerPlanRoutes(apiGroup)
s.registerSheetRoutes(apiGroup)
s.registerSheetOrganizerRoutes(apiGroup)
@@ -539,6 +538,12 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
return nil
}))
v1pb.RegisterActuatorServiceServer(s.grpcServer, v1.NewActuatorService(s.store, &s.profile))
+ v1pb.RegisterSubscriptionServiceServer(s.grpcServer, v1.NewSubscriptionService(
+ s.workspaceID,
+ s.store,
+ &s.profile,
+ s.MetricReporter,
+ s.licenseService))
v1pb.RegisterEnvironmentServiceServer(s.grpcServer, v1.NewEnvironmentService(s.store, s.licenseService))
v1pb.RegisterInstanceServiceServer(s.grpcServer, v1.NewInstanceService(s.store, s.licenseService, s.secret))
v1pb.RegisterProjectServiceServer(s.grpcServer, v1.NewProjectService(s.store))
@@ -567,6 +572,9 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
if err := v1pb.RegisterActuatorServiceHandler(ctx, mux, grpcConn); err != nil {
return nil, err
}
+ if err := v1pb.RegisterSubscriptionServiceHandler(ctx, mux, grpcConn); err != nil {
+ return nil, err
+ }
if err := v1pb.RegisterEnvironmentServiceHandler(ctx, mux, grpcConn); err != nil {
return nil, err
}
diff --git a/backend/server/subscription.go b/backend/server/subscription.go
deleted file mode 100644
index 7e5e59baca..0000000000
--- a/backend/server/subscription.go
+++ /dev/null
@@ -1,164 +0,0 @@
-package server
-
-import (
- "encoding/json"
- "fmt"
- "net/http"
- "time"
-
- "github.com/google/jsonapi"
- "github.com/labstack/echo/v4"
-
- "github.com/bytebase/bytebase/backend/common"
- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"
- api "github.com/bytebase/bytebase/backend/legacyapi"
- metricAPI "github.com/bytebase/bytebase/backend/metric"
- "github.com/bytebase/bytebase/backend/plugin/metric"
- "github.com/bytebase/bytebase/backend/store"
-)
-
-func (s *Server) registerSubscriptionRoutes(g *echo.Group) {
- g.GET("/subscription", func(c echo.Context) error {
- ctx := c.Request().Context()
- subscription := s.licenseService.LoadSubscription(ctx)
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- if err := jsonapi.MarshalPayload(c.Response().Writer, &subscription); err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal subscription response").SetInternal(err)
- }
- return nil
- })
-
- g.PATCH("/subscription", func(c echo.Context) error {
- patch := &enterpriseAPI.SubscriptionPatch{}
- ctx := c.Request().Context()
- if err := jsonapi.UnmarshalPayload(c.Request().Body, patch); err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, "Malformed create subscription request").SetInternal(err)
- }
- patch.UpdaterID = c.Get(getPrincipalIDContextKey()).(int)
-
- // clear the trialing setting for dev test
- if patch.License == "" && s.profile.Mode == common.ReleaseModeDev {
- if err := s.store.DeleteSettingV2(ctx, api.SettingEnterpriseTrial); err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to delete the trialing license").SetInternal(err)
- }
- }
-
- if err := s.licenseService.StoreLicense(ctx, patch); err != nil {
- if common.ErrorCode(err) == common.Invalid {
- return echo.NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
- }
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to store license").SetInternal(err)
- }
-
- subscription := s.licenseService.LoadSubscription(ctx)
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- if err := jsonapi.MarshalPayload(c.Response().Writer, &subscription); err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal subscription response").SetInternal(err)
- }
- return nil
- })
-
- g.POST("/subscription/trial", func(c echo.Context) error {
- ctx := c.Request().Context()
-
- create := &api.TrialPlanCreate{}
- if err := jsonapi.UnmarshalPayload(c.Request().Body, create); err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, "Malformed create trial request").SetInternal(err)
- }
- license := &enterpriseAPI.License{
- InstanceCount: create.InstanceCount,
- Seat: create.Seat,
- ExpiresTs: time.Now().AddDate(0, 0, create.Days).Unix(),
- IssuedTs: time.Now().Unix(),
- Plan: create.Type,
- // the subject format for license should be {org id in hub}.{subscription id in hub}
- // as we just need to simply generate the trialing license in console, we can use the workspace id instead.
- Subject: fmt.Sprintf("%s.%s", s.workspaceID, ""),
- Trialing: true,
- OrgName: s.workspaceID,
- }
-
- subscription := s.licenseService.LoadSubscription(ctx)
- basePlan := subscription.Plan
- if license.Plan.Priority() <= subscription.Plan.Priority() {
- // Ignore the request if the priority for the trial plan is lower than the current plan.
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- if err := jsonapi.MarshalPayload(c.Response().Writer, &subscription); err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal subscription response").SetInternal(err)
- }
- return nil
- }
-
- if subscription.Trialing {
- license.ExpiresTs = subscription.ExpiresTs
- license.IssuedTs = subscription.StartedTs
- }
-
- value, err := json.Marshal(license)
- if err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal license").SetInternal(err)
- }
-
- principalID := c.Get(getPrincipalIDContextKey()).(int)
- settingName := api.SettingEnterpriseTrial
- settings, err := s.store.FindSetting(ctx, &api.SettingFind{
- Name: &settingName,
- })
- if err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find setting").SetInternal(err)
- }
-
- if len(settings) == 0 {
- // We will create a new setting named SettingEnterpriseTrial to store the free trial license.
- _, created, err := s.store.CreateSettingIfNotExistV2(ctx, &store.SettingMessage{
- Name: api.SettingEnterpriseTrial,
- Value: string(value),
- Description: "The trialing license.",
- }, principalID)
- if err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create license").SetInternal(err)
- }
-
- if created && subscription.Trialing {
- // For trial upgrade
- // Case 1: Users just have the SettingEnterpriseTrial, don't upload their license in SettingEnterpriseLicense.
- // Case 2: Users have the SettingEnterpriseLicense with team plan and trialing status.
- // In both cases, we can override the SettingEnterpriseLicense with an empty value to get the valid free trial.
- if err := s.licenseService.StoreLicense(ctx, &enterpriseAPI.SubscriptionPatch{
- UpdaterID: principalID,
- License: "",
- }); err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to remove license").SetInternal(err)
- }
- }
- } else {
- // Update the existed free trial.
- if _, err := s.store.PatchSetting(ctx, &api.SettingPatch{
- UpdaterID: principalID,
- Name: api.SettingEnterpriseTrial,
- Value: string(value),
- }); err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to patch license").SetInternal(err)
- }
- }
-
- s.licenseService.RefreshCache(ctx)
- subscription = s.licenseService.LoadSubscription(ctx)
- currentPlan := subscription.Plan
- s.MetricReporter.Report(&metric.Metric{
- Name: metricAPI.SubscriptionTrialMetricName,
- Value: 1,
- Labels: map[string]interface{}{
- "trial_plan": currentPlan.String(),
- "from_plan": basePlan.String(),
- "lark_notified": false,
- },
- })
-
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
- if err := jsonapi.MarshalPayload(c.Response().Writer, &subscription); err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal subscription response").SetInternal(err)
- }
- return nil
- })
-}
diff --git a/backend/store/setting.go b/backend/store/setting.go
index 379a9a93fa..c226ac774a 100644
--- a/backend/store/setting.go
+++ b/backend/store/setting.go
@@ -274,6 +274,8 @@ func (s *Store) DeleteSettingV2(ctx context.Context, name api.SettingName) error
if err := tx.Commit(); err != nil {
return errors.Wrap(err, "failed to commit transaction")
}
+
+ s.settingCache.Delete(name)
return nil
}
diff --git a/backend/tests/subscription.go b/backend/tests/subscription.go
index 8a1acf90d9..3523e0093f 100644
--- a/backend/tests/subscription.go
+++ b/backend/tests/subscription.go
@@ -2,25 +2,24 @@ package tests
import (
"bytes"
+ "io"
- "github.com/google/jsonapi"
"github.com/pkg/errors"
+ "google.golang.org/protobuf/encoding/protojson"
- enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"
-
- api "github.com/bytebase/bytebase/backend/legacyapi"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
func (ctl *controller) setLicense() error {
- return ctl.trialPlan(&api.TrialPlanCreate{
+ return ctl.trialPlan(&v1pb.TrialSubscription{
InstanceCount: 100,
- Type: api.ENTERPRISE,
+ Plan: v1pb.PlanType_ENTERPRISE,
Days: 1,
})
}
func (ctl *controller) removeLicense() error {
- err := ctl.switchPlan(&enterpriseAPI.SubscriptionPatch{
+ err := ctl.switchPlan(&v1pb.PatchSubscription{
License: "",
})
if err != nil {
@@ -29,37 +28,41 @@ func (ctl *controller) removeLicense() error {
return nil
}
-func (ctl *controller) getSubscription() (*enterpriseAPI.Subscription, error) {
- body, err := ctl.get("/subscription", nil)
+func (ctl *controller) getSubscription() (*v1pb.Subscription, error) {
+ body, err := ctl.getOpenAPI("/subscription", nil)
+ if err != nil {
+ return nil, err
+ }
+ bs, err := io.ReadAll(body)
if err != nil {
return nil, err
}
- subscription := new(enterpriseAPI.Subscription)
- if err = jsonapi.UnmarshalPayload(body, subscription); err != nil {
+ subscription := new(v1pb.Subscription)
+ if err = protojson.Unmarshal(bs, subscription); err != nil {
return nil, errors.Wrap(err, "fail to unmarshal get subscription response")
}
return subscription, nil
}
-func (ctl *controller) trialPlan(trial *api.TrialPlanCreate) error {
- buf := new(bytes.Buffer)
- if err := jsonapi.MarshalPayload(buf, trial); err != nil {
+func (ctl *controller) trialPlan(trial *v1pb.TrialSubscription) error {
+ bs, err := protojson.Marshal(trial)
+ if err != nil {
return errors.Wrap(err, "failed to marshal subscription patch")
}
-
- _, err := ctl.post("/subscription/trial", buf)
- return err
+ if _, err := ctl.postOpenAPI("/subscription/trial", bytes.NewReader(bs)); err != nil {
+ return err
+ }
+ return nil
}
-func (ctl *controller) switchPlan(patch *enterpriseAPI.SubscriptionPatch) error {
- buf := new(bytes.Buffer)
- if err := jsonapi.MarshalPayload(buf, patch); err != nil {
+func (ctl *controller) switchPlan(patch *v1pb.PatchSubscription) error {
+ bs, err := protojson.Marshal(patch)
+ if err != nil {
return errors.Wrap(err, "failed to marshal subscription patch")
}
- _, err := ctl.patch("/subscription", buf)
- if err != nil {
+ if _, err := ctl.patchOpenAPI("/subscription", bytes.NewReader(bs)); err != nil {
return err
}
diff --git a/backend/tests/subscription_test.go b/backend/tests/subscription_test.go
index 206ca0ddd3..f72ca64028 100644
--- a/backend/tests/subscription_test.go
+++ b/backend/tests/subscription_test.go
@@ -8,16 +8,17 @@ import (
"go.uber.org/zap/zapcore"
"github.com/bytebase/bytebase/backend/common/log"
- api "github.com/bytebase/bytebase/backend/legacyapi"
"github.com/bytebase/bytebase/backend/tests/fake"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
type trial struct {
- instanceCount int
- expectInstanceCount int
- plan api.PlanType
- expectPlan api.PlanType
- Days int
+ seat int32
+ instanceCount int32
+ expectInstanceCount int32
+ plan v1pb.PlanType
+ expectPlan v1pb.PlanType
+ Days int32
}
func TestSubscription(t *testing.T) {
@@ -35,39 +36,43 @@ func TestSubscription(t *testing.T) {
subscription, err := ctl.getSubscription()
a.NoError(err)
- a.Equal(api.FREE, subscription.Plan)
+ a.Equal(v1pb.PlanType_FREE, subscription.Plan)
trialList := []trial{
{
// Test trial the TEAM plan.
+ seat: 10,
instanceCount: 20,
expectInstanceCount: 20,
- plan: api.TEAM,
- expectPlan: api.TEAM,
+ plan: v1pb.PlanType_TEAM,
+ expectPlan: v1pb.PlanType_TEAM,
Days: 7,
},
{
// Test trial the ENTERPRISE plan.
+ seat: 10,
instanceCount: 10,
expectInstanceCount: 10,
- plan: api.ENTERPRISE,
- expectPlan: api.ENTERPRISE,
+ plan: v1pb.PlanType_ENTERPRISE,
+ expectPlan: v1pb.PlanType_ENTERPRISE,
Days: 7,
},
{
// Downgrade should be ignored.
+ seat: 10,
instanceCount: 99,
expectInstanceCount: 10,
- plan: api.TEAM,
- expectPlan: api.ENTERPRISE,
+ plan: v1pb.PlanType_TEAM,
+ expectPlan: v1pb.PlanType_ENTERPRISE,
Days: 7,
},
}
for _, trial := range trialList {
- err = ctl.trialPlan(&api.TrialPlanCreate{
+ err = ctl.trialPlan(&v1pb.TrialSubscription{
+ Seat: trial.seat,
InstanceCount: trial.instanceCount,
- Type: trial.plan,
+ Plan: trial.plan,
Days: trial.Days,
})
a.NoError(err)
diff --git a/backend/tests/tests.go b/backend/tests/tests.go
index 4203cf3b20..738d3a5482 100644
--- a/backend/tests/tests.go
+++ b/backend/tests/tests.go
@@ -525,106 +525,79 @@ func (*controller) provisionSQLiteInstance(rootDir, name string) (string, error)
// get sends a GET client request.
func (ctl *controller) get(shortURL string, params map[string]string) (io.ReadCloser, error) {
gURL := fmt.Sprintf("%s%s", ctl.apiURL, shortURL)
- req, err := http.NewRequest("GET", gURL, nil)
- if err != nil {
- return nil, errors.Wrapf(err, "fail to create a new GET request(%q)", gURL)
- }
- req.Header.Set("Cookie", ctl.cookie)
- q := url.Values{}
- for k, v := range params {
- q.Add(k, v)
- }
- req.URL.RawQuery = q.Encode()
- resp, err := ctl.client.Do(req)
- if err != nil {
- return nil, errors.Wrapf(err, "fail to send a GET request(%q)", gURL)
- }
- if resp.StatusCode != http.StatusOK {
- body, err := io.ReadAll(resp.Body)
- if err != nil {
- return nil, errors.Wrap(err, "failed to read http response body")
- }
- return nil, errors.Errorf("http response error code %v body %q", resp.StatusCode, string(body))
- }
- return resp.Body, nil
+ return ctl.request("GET", gURL, nil, params, map[string]string{
+ "Cookie": ctl.cookie,
+ })
+}
+
+// OpenAPI sends a GET OpenAPI client request.
+func (ctl *controller) getOpenAPI(shortURL string, params map[string]string) (io.ReadCloser, error) {
+ gURL := fmt.Sprintf("%s%s", ctl.v1APIURL, shortURL)
+ return ctl.request("GET", gURL, nil, params, map[string]string{
+ "Authorization": fmt.Sprintf("Bearer %s", strings.ReplaceAll(ctl.cookie, "access-token=", "")),
+ })
}
// postOpenAPI sends a openAPI POST request.
func (ctl *controller) postOpenAPI(shortURL string, body io.Reader) (io.ReadCloser, error) {
url := fmt.Sprintf("%s%s", ctl.v1APIURL, shortURL)
- req, err := http.NewRequest("POST", url, body)
- if err != nil {
- return nil, errors.Wrapf(err, "fail to create a new POST request(%q)", url)
- }
- req.Header.Set("Cookie", ctl.cookie)
- resp, err := ctl.client.Do(req)
- if err != nil {
- return nil, errors.Wrapf(err, "fail to send a POST request(%q)", url)
- }
- if resp.StatusCode != http.StatusOK {
- body, err := io.ReadAll(resp.Body)
- if err != nil {
- return nil, errors.Wrap(err, "failed to read http response body")
- }
- return nil, errors.Errorf("http response error code %v body %q", resp.StatusCode, string(body))
- }
- return resp.Body, nil
+ return ctl.request("POST", url, body, nil, map[string]string{
+ "Authorization": fmt.Sprintf("Bearer %s", strings.ReplaceAll(ctl.cookie, "access-token=", "")),
+ })
}
// post sends a POST client request.
func (ctl *controller) post(shortURL string, body io.Reader) (io.ReadCloser, error) {
url := fmt.Sprintf("%s%s", ctl.apiURL, shortURL)
- req, err := http.NewRequest("POST", url, body)
- if err != nil {
- return nil, errors.Wrapf(err, "fail to create a new POST request(%q)", url)
- }
- req.Header.Set("Cookie", ctl.cookie)
- resp, err := ctl.client.Do(req)
- if err != nil {
- return nil, errors.Wrapf(err, "fail to send a POST request(%q)", url)
- }
- if resp.StatusCode != http.StatusOK {
- body, err := io.ReadAll(resp.Body)
- if err != nil {
- return nil, errors.Wrap(err, "failed to read http response body")
- }
- return nil, errors.Errorf("http response error code %v body %q", resp.StatusCode, string(body))
- }
- return resp.Body, nil
+ return ctl.request("POST", url, body, nil, map[string]string{
+ "Cookie": ctl.cookie,
+ })
}
// patch sends a PATCH client request.
func (ctl *controller) patch(shortURL string, body io.Reader) (io.ReadCloser, error) {
url := fmt.Sprintf("%s%s", ctl.apiURL, shortURL)
- req, err := http.NewRequest("PATCH", url, body)
- if err != nil {
- return nil, errors.Wrapf(err, "fail to create a new PATCH request(%q)", url)
- }
- req.Header.Set("Cookie", ctl.cookie)
- resp, err := ctl.client.Do(req)
- if err != nil {
- return nil, errors.Wrapf(err, "fail to send a PATCH request(%q)", url)
- }
- if resp.StatusCode != http.StatusOK {
- body, err := io.ReadAll(resp.Body)
- if err != nil {
- return nil, errors.Wrap(err, "failed to read http response body")
- }
- return nil, errors.Errorf("http response error code %v body %q", resp.StatusCode, string(body))
- }
- return resp.Body, nil
+ return ctl.request("PATCH", url, body, nil, map[string]string{
+ "Cookie": ctl.cookie,
+ })
+}
+
+// patchOpenAPI sends a openAPI PATCH client request.
+func (ctl *controller) patchOpenAPI(shortURL string, body io.Reader) (io.ReadCloser, error) {
+ url := fmt.Sprintf("%s%s", ctl.v1APIURL, shortURL)
+ return ctl.request("PATCH", url, body, nil, map[string]string{
+ "Authorization": fmt.Sprintf("Bearer %s", strings.ReplaceAll(ctl.cookie, "access-token=", "")),
+ })
}
func (ctl *controller) delete(shortURL string, body io.Reader) (io.ReadCloser, error) {
url := fmt.Sprintf("%s%s", ctl.apiURL, shortURL)
- req, err := http.NewRequest("DELETE", url, body)
+ return ctl.request("DELETE", url, body, nil, map[string]string{
+ "Cookie": ctl.cookie,
+ })
+}
+
+func (ctl *controller) request(method, fullURL string, body io.Reader, params, header map[string]string) (io.ReadCloser, error) {
+ req, err := http.NewRequest(method, fullURL, body)
if err != nil {
- return nil, errors.Wrapf(err, "fail to create a new DELETE request(%q)", url)
+ return nil, errors.Wrapf(err, "fail to create a new %s request(%q)", method, fullURL)
}
- req.Header.Set("Cookie", ctl.cookie)
+
+ for k, v := range header {
+ req.Header.Set(k, v)
+ }
+
+ q := url.Values{}
+ for k, v := range params {
+ q.Add(k, v)
+ }
+ if len(q) > 0 {
+ req.URL.RawQuery = q.Encode()
+ }
+
resp, err := ctl.client.Do(req)
if err != nil {
- return nil, errors.Wrapf(err, "fail to send a DELETE request(%q)", url)
+ return nil, errors.Wrapf(err, "fail to send a %s request(%q)", method, fullURL)
}
if resp.StatusCode != http.StatusOK {
body, err := io.ReadAll(resp.Body)
diff --git a/frontend/src/components/FeatureAttention.vue b/frontend/src/components/FeatureAttention.vue
index 85cb5b9506..170a5954ba 100644
--- a/frontend/src/components/FeatureAttention.vue
+++ b/frontend/src/components/FeatureAttention.vue
@@ -11,10 +11,11 @@
<script lang="ts" setup>
import { PropType, computed } from "vue";
-import { FeatureType, PlanType, planTypeToString } from "@/types";
+import { FeatureType, planTypeToString } from "@/types";
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
import { useSubscriptionStore, pushNotification } from "@/store";
+import { PlanType } from "@/types/proto/v1/subscription_service";
const props = defineProps({
feature: {
@@ -73,26 +74,24 @@ const descriptionText = computed(() => {
const onClick = () => {
if (subscriptionStore.canTrial) {
const isUpgrade = subscriptionStore.canUpgradeTrial;
- subscriptionStore
- .trialSubscription(PlanType.ENTERPRISE)
- .then((subscription) => {
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.success"),
- description: isUpgrade
- ? t("subscription.successfully-upgrade-trial", {
- plan: t(
- `subscription.plan.${planTypeToString(
- subscription.plan
- )}.title`
- ),
- })
- : t("subscription.successfully-start-trial", {
- days: subscriptionStore.trialingDays,
- }),
- });
+ subscriptionStore.trialSubscription(PlanType.ENTERPRISE).then(() => {
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.success"),
+ description: isUpgrade
+ ? t("subscription.successfully-upgrade-trial", {
+ plan: t(
+ `subscription.plan.${planTypeToString(
+ subscriptionStore.currentPlan
+ )}.title`
+ ),
+ })
+ : t("subscription.successfully-start-trial", {
+ days: subscriptionStore.trialingDays,
+ }),
});
+ });
} else {
router.push({ name: "setting.workspace.subscription" });
}
diff --git a/frontend/src/components/FeatureModal.vue b/frontend/src/components/FeatureModal.vue
index 7b142286af..b6a6f24471 100644
--- a/frontend/src/components/FeatureModal.vue
+++ b/frontend/src/components/FeatureModal.vue
@@ -104,7 +104,8 @@ import { PropType } from "vue";
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
import { useSubscriptionStore, pushNotification } from "@/store";
-import { FeatureType, PlanType, planTypeToString } from "@/types";
+import { FeatureType, planTypeToString } from "@/types";
+import { PlanType } from "@/types/proto/v1/subscription_service";
const props = defineProps({
feature: {
@@ -132,25 +133,25 @@ const featureKey = props.feature.split(".").join("-");
const trialSubscription = () => {
const isUpgrade = subscriptionStore.canUpgradeTrial;
- subscriptionStore
- .trialSubscription(PlanType.ENTERPRISE)
- .then((subscription) => {
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.success"),
- description: isUpgrade
- ? t("subscription.successfully-upgrade-trial", {
- plan: t(
- `subscription.plan.${planTypeToString(subscription.plan)}.title`
- ),
- })
- : t("subscription.successfully-start-trial", {
- days: subscriptionStore.trialingDays,
- }),
- });
- emit("cancel");
+ subscriptionStore.trialSubscription(PlanType.ENTERPRISE).then(() => {
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.success"),
+ description: isUpgrade
+ ? t("subscription.successfully-upgrade-trial", {
+ plan: t(
+ `subscription.plan.${planTypeToString(
+ subscriptionStore.currentPlan
+ )}.title`
+ ),
+ })
+ : t("subscription.successfully-start-trial", {
+ days: subscriptionStore.trialingDays,
+ }),
});
+ emit("cancel");
+ });
};
</script>
diff --git a/frontend/src/components/PricingTable/PricingTable.vue b/frontend/src/components/PricingTable/PricingTable.vue
index c252431a50..9d64033cb8 100644
--- a/frontend/src/components/PricingTable/PricingTable.vue
+++ b/frontend/src/components/PricingTable/PricingTable.vue
@@ -278,10 +278,11 @@
<script lang="ts" setup>
import { reactive, computed, watch } from "vue";
import { useI18n } from "vue-i18n";
-import { Plan, PlanType, PLANS, FEATURE_SECTIONS } from "@/types";
+import { Plan, PLANS, FEATURE_SECTIONS } from "@/types";
import { useSubscriptionStore } from "@/store";
import { LocalPlan } from "./types";
import FeatureItem from "./FeatureItem.vue";
+import { PlanType } from "@/types/proto/v1/subscription_service";
interface LocalState {
isMonthly: boolean;
diff --git a/frontend/src/components/TrialModal.vue b/frontend/src/components/TrialModal.vue
index 18b70b7b0d..90357c3c11 100644
--- a/frontend/src/components/TrialModal.vue
+++ b/frontend/src/components/TrialModal.vue
@@ -56,7 +56,8 @@
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
import { useSubscriptionStore, pushNotification } from "@/store";
-import { PlanType, planTypeToString } from "@/types";
+import { planTypeToString } from "@/types";
+import { PlanType } from "@/types/proto/v1/subscription_service";
const emit = defineEmits(["cancel"]);
const { t } = useI18n();
diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vue
index e51a579664..11ed032129 100644
--- a/frontend/src/layouts/BodyLayout.vue
+++ b/frontend/src/layouts/BodyLayout.vue
@@ -239,7 +239,7 @@ import Quickstart from "../components/Quickstart.vue";
import QuickActionPanel from "../components/QuickActionPanel.vue";
import { QuickActionType } from "../types";
import { isDBA, isDeveloper, isOwner } from "../utils";
-import { PlanType } from "../types";
+import { PlanType } from "@/types/proto/v1/subscription_service";
import {
useActuatorStore,
useCurrentUser,
diff --git a/frontend/src/store/modules/actuator.ts b/frontend/src/store/modules/actuator.ts
index f367ac95bb..781c1413a1 100644
--- a/frontend/src/store/modules/actuator.ts
+++ b/frontend/src/store/modules/actuator.ts
@@ -1,9 +1,10 @@
import axios from "axios";
import { defineStore } from "pinia";
-import { ActuatorState, ServerInfo, Release } from "@/types";
+import { ActuatorState, Release } from "@/types";
import { useLocalStorage } from "@vueuse/core";
import { semverCompare } from "@/utils";
import { useSilentRequest } from "@/plugins/silent-request";
+import { ActuatorInfo } from "@/types/proto/v1/actuator_service";
const EXTERNAL_URL_PLACEHOLDER =
"https://www.bytebase.com/docs/get-started/install/external-url";
@@ -59,11 +60,11 @@ export const useActuatorStore = defineStore("actuator", {
},
},
actions: {
- setServerInfo(serverInfo: ServerInfo) {
+ setServerInfo(serverInfo: ActuatorInfo) {
this.serverInfo = serverInfo;
},
async fetchServerInfo() {
- const { data: serverInfo } = await axios.get<ServerInfo>(
+ const { data: serverInfo } = await axios.get<ActuatorInfo>(
`/v1/actuator/info`
);
diff --git a/frontend/src/store/modules/subscription.ts b/frontend/src/store/modules/subscription.ts
index ab04121167..5b71d59bdc 100644
--- a/frontend/src/store/modules/subscription.ts
+++ b/frontend/src/store/modules/subscription.ts
@@ -3,13 +3,12 @@ import axios from "axios";
import dayjs from "dayjs";
import { computed, Ref } from "vue";
import { useI18n } from "vue-i18n";
+import { FeatureType, SubscriptionState, planTypeToString } from "@/types";
import {
- Subscription,
- FeatureType,
PlanType,
- SubscriptionState,
- planTypeToString,
-} from "@/types";
+ Subscription,
+ planTypeFromJSON,
+} from "@/types/proto/v1/subscription_service";
export const useSubscriptionStore = defineStore("subscription", {
state: (): SubscriptionState => ({
@@ -33,50 +32,68 @@ export const useSubscriptionStore = defineStore("subscription", {
return count;
},
currentPlan(state): PlanType {
- return state.subscription?.plan ?? PlanType.FREE;
+ if (!state.subscription) {
+ return PlanType.FREE;
+ }
+ return planTypeFromJSON(state.subscription.plan);
+ },
+ isFreePlan(state): boolean {
+ return this.currentPlan == PlanType.FREE;
},
expireAt(state): string {
- if (!state.subscription || state.subscription.expiresTs <= 0) {
+ if (
+ !state.subscription ||
+ !state.subscription.expiresTime ||
+ this.isFreePlan
+ ) {
return "";
}
- return dayjs(state.subscription.expiresTs * 1000).format("YYYY-MM-DD");
+ return dayjs(state.subscription.expiresTime).format("YYYY-MM-DD");
},
isTrialing(state): boolean {
return !!state.subscription?.trialing;
},
isExpired(state): boolean {
- if (!state.subscription || state.subscription.expiresTs <= 0) {
+ if (
+ !state.subscription ||
+ !state.subscription.expiresTime ||
+ this.isFreePlan
+ ) {
return false;
}
- return dayjs(state.subscription.expiresTs * 1000).isBefore(new Date());
+ return dayjs(state.subscription.expiresTime).isBefore(new Date());
},
daysBeforeExpire(state): number {
- if (!state.subscription || state.subscription.expiresTs <= 0) {
+ if (
+ !state.subscription ||
+ !state.subscription.expiresTime ||
+ this.isFreePlan
+ ) {
return -1;
}
- const expiresTime = dayjs(state.subscription.expiresTs * 1000);
+ const expiresTime = dayjs(state.subscription.expiresTime);
return Math.max(expiresTime.diff(new Date(), "day"), 0);
},
isNearExpireTime(state): boolean {
- if (!state.subscription || !state.subscription?.trialing) return false;
+ if (
+ !state.subscription ||
+ !state.subscription?.trialing ||
+ this.isFreePlan
+ ) {
+ return false;
+ }
const daysBeforeExpire = this.daysBeforeExpire;
if (daysBeforeExpire <= 0) return false;
- const trialEndTime = dayjs(state.subscription.expiresTs * 1000);
- const total = trialEndTime.diff(
- state.subscription.startedTs * 1000,
- "day"
- );
+ const trialEndTime = dayjs(state.subscription.expiresTime);
+ const total = trialEndTime.diff(state.subscription.startedTime, "day");
return daysBeforeExpire / total < 0.5;
},
canTrial(state): boolean {
- if (!state.subscription) {
- return true;
- }
- if (state.subscription.plan === PlanType.FREE) {
+ if (!state.subscription || this.isFreePlan) {
return true;
}
return this.canUpgradeTrial;
@@ -86,8 +103,7 @@ export const useSubscriptionStore = defineStore("subscription", {
return false;
}
return (
- state.subscription.trialing &&
- state.subscription.plan < PlanType.ENTERPRISE
+ state.subscription.trialing && this.currentPlan < PlanType.ENTERPRISE
);
},
},
@@ -127,8 +143,9 @@ export const useSubscriptionStore = defineStore("subscription", {
},
async fetchSubscription() {
try {
- const data = (await axios.get(`/api/subscription`)).data.data;
- const subscription = data.attributes as Subscription;
+ const { data: subscription } = await axios.get<Subscription>(
+ `/v1/subscription`
+ );
this.setSubscription(subscription);
return subscription;
} catch (e) {
@@ -148,35 +165,25 @@ export const useSubscriptionStore = defineStore("subscription", {
}
},
async patchSubscription(license: string) {
- const data = (
- await axios.patch(`/api/subscription`, {
- data: {
- type: "SubscriptionPatch",
- attributes: {
- license,
- },
- },
- })
- ).data.data;
- const subscription = data.attributes as Subscription;
+ const { data: subscription } = await axios.patch<Subscription>(
+ `/v1/subscription`,
+ {
+ license,
+ }
+ );
this.setSubscription(subscription);
return subscription;
},
async trialSubscription(planType: PlanType) {
- const data = (
- await axios.post(`/api/subscription/trial`, {
- data: {
- type: "TrialPlanCreate",
- attributes: {
- type: planType,
- days: this.trialingDays,
- seat: 10,
- instanceCount: -1,
- },
- },
- })
- ).data.data;
- const subscription = data.attributes as Subscription;
+ const { data: subscription } = await axios.post<Subscription>(
+ `/v1/subscription/trial`,
+ {
+ plan: planType,
+ days: this.trialingDays,
+ seat: 10,
+ instanceCount: -1,
+ }
+ );
this.setSubscription(subscription);
return subscription;
},
diff --git a/frontend/src/types/plan.ts b/frontend/src/types/plan.ts
index 1cb53d5316..df6b970cde 100644
--- a/frontend/src/types/plan.ts
+++ b/frontend/src/types/plan.ts
@@ -1,5 +1,6 @@
import { useI18n } from "vue-i18n";
import planData from "./plan.yaml";
+import { PlanType } from "@/types/proto/v1/subscription_service";
// Check api/plan.go to understand what each feature means.
export type FeatureType =
@@ -39,12 +40,6 @@ export type FeatureType =
// Plugins
| "bb.feature.plugin.openai";
-export enum PlanType {
- FREE = 0,
- TEAM = 1,
- ENTERPRISE = 2,
-}
-
export const planTypeToString = (planType: PlanType): string => {
switch (planType) {
case PlanType.FREE:
@@ -53,6 +48,8 @@ export const planTypeToString = (planType: PlanType): string => {
return "team";
case PlanType.ENTERPRISE:
return "enterprise";
+ default:
+ return "";
}
};
diff --git a/frontend/src/types/proto/v1/subscription_service.ts b/frontend/src/types/proto/v1/subscription_service.ts
new file mode 100644
index 0000000000..69ceccc465
--- /dev/null
+++ b/frontend/src/types/proto/v1/subscription_service.ts
@@ -0,0 +1,731 @@
+/* eslint-disable */
+import type { CallContext, CallOptions } from "nice-grpc-common";
+import * as _m0 from "protobufjs/minimal";
+import { Timestamp } from "../google/protobuf/timestamp";
+
+export const protobufPackage = "bytebase.v1";
+
+export enum PlanType {
+ PLAN_TYPE_UNSPECIFIED = 0,
+ FREE = 1,
+ TEAM = 2,
+ ENTERPRISE = 3,
+ UNRECOGNIZED = -1,
+}
+
+export function planTypeFromJSON(object: any): PlanType {
+ switch (object) {
+ case 0:
+ case "PLAN_TYPE_UNSPECIFIED":
+ return PlanType.PLAN_TYPE_UNSPECIFIED;
+ case 1:
+ case "FREE":
+ return PlanType.FREE;
+ case 2:
+ case "TEAM":
+ return PlanType.TEAM;
+ case 3:
+ case "ENTERPRISE":
+ return PlanType.ENTERPRISE;
+ case -1:
+ case "UNRECOGNIZED":
+ default:
+ return PlanType.UNRECOGNIZED;
+ }
+}
+
+export function planTypeToJSON(object: PlanType): string {
+ switch (object) {
+ case PlanType.PLAN_TYPE_UNSPECIFIED:
+ return "PLAN_TYPE_UNSPECIFIED";
+ case PlanType.FREE:
+ return "FREE";
+ case PlanType.TEAM:
+ return "TEAM";
+ case PlanType.ENTERPRISE:
+ return "ENTERPRISE";
+ case PlanType.UNRECOGNIZED:
+ default:
+ return "UNRECOGNIZED";
+ }
+}
+
+export interface GetSubscriptionRequest {
+}
+
+export interface UpdateSubscriptionRequest {
+ patch?: PatchSubscription;
+}
+
+export interface TrialSubscriptionRequest {
+ trial?: TrialSubscription;
+}
+
+export interface PatchSubscription {
+ license: string;
+}
+
+export interface TrialSubscription {
+ plan: PlanType;
+ days: number;
+ seat: number;
+ instanceCount: number;
+}
+
+export interface Subscription {
+ seat: number;
+ instanceCount: number;
+ expiresTime?: Date;
+ startedTime?: Date;
+ plan: PlanType;
+ trialing: boolean;
+ orgId: string;
+ orgName: string;
+}
+
+function createBaseGetSubscriptionRequest(): GetSubscriptionRequest {
+ return {};
+}
+
+export const GetSubscriptionRequest = {
+ encode(_: GetSubscriptionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): GetSubscriptionRequest {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseGetSubscriptionRequest();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ }
+ if ((tag & 7) == 4 || tag == 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(_: any): GetSubscriptionRequest {
+ return {};
+ },
+
+ toJSON(_: GetSubscriptionRequest): unknown {
+ const obj: any = {};
+ return obj;
+ },
+
+ create(base?: DeepPartial<GetSubscriptionRequest>): GetSubscriptionRequest {
+ return GetSubscriptionRequest.fromPartial(base ?? {});
+ },
+
+ fromPartial(_: DeepPartial<GetSubscriptionRequest>): GetSubscriptionRequest {
+ const message = createBaseGetSubscriptionRequest();
+ return message;
+ },
+};
+
+function createBaseUpdateSubscriptionRequest(): UpdateSubscriptionRequest {
+ return { patch: undefined };
+}
+
+export const UpdateSubscriptionRequest = {
+ encode(message: UpdateSubscriptionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.patch !== undefined) {
+ PatchSubscription.encode(message.patch, writer.uint32(10).fork()).ldelim();
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): UpdateSubscriptionRequest {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseUpdateSubscriptionRequest();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag != 10) {
+ break;
+ }
+
+ message.patch = PatchSubscription.decode(reader, reader.uint32());
+ continue;
+ }
+ if ((tag & 7) == 4 || tag == 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): UpdateSubscriptionRequest {
+ return { patch: isSet(object.patch) ? PatchSubscription.fromJSON(object.patch) : undefined };
+ },
+
+ toJSON(message: UpdateSubscriptionRequest): unknown {
+ const obj: any = {};
+ message.patch !== undefined && (obj.patch = message.patch ? PatchSubscription.toJSON(message.patch) : undefined);
+ return obj;
+ },
+
+ create(base?: DeepPartial<UpdateSubscriptionRequest>): UpdateSubscriptionRequest {
+ return UpdateSubscriptionRequest.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<UpdateSubscriptionRequest>): UpdateSubscriptionRequest {
+ const message = createBaseUpdateSubscriptionRequest();
+ message.patch = (object.patch !== undefined && object.patch !== null)
+ ? PatchSubscription.fromPartial(object.patch)
+ : undefined;
+ return message;
+ },
+};
+
+function createBaseTrialSubscriptionRequest(): TrialSubscriptionRequest {
+ return { trial: undefined };
+}
+
+export const TrialSubscriptionRequest = {
+ encode(message: TrialSubscriptionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.trial !== undefined) {
+ TrialSubscription.encode(message.trial, writer.uint32(10).fork()).ldelim();
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): TrialSubscriptionRequest {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseTrialSubscriptionRequest();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag != 10) {
+ break;
+ }
+
+ message.trial = TrialSubscription.decode(reader, reader.uint32());
+ continue;
+ }
+ if ((tag & 7) == 4 || tag == 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): TrialSubscriptionRequest {
+ return { trial: isSet(object.trial) ? TrialSubscription.fromJSON(object.trial) : undefined };
+ },
+
+ toJSON(message: TrialSubscriptionRequest): unknown {
+ const obj: any = {};
+ message.trial !== undefined && (obj.trial = message.trial ? TrialSubscription.toJSON(message.trial) : undefined);
+ return obj;
+ },
+
+ create(base?: DeepPartial<TrialSubscriptionRequest>): TrialSubscriptionRequest {
+ return TrialSubscriptionRequest.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<TrialSubscriptionRequest>): TrialSubscriptionRequest {
+ const message = createBaseTrialSubscriptionRequest();
+ message.trial = (object.trial !== undefined && object.trial !== null)
+ ? TrialSubscription.fromPartial(object.trial)
+ : undefined;
+ return message;
+ },
+};
+
+function createBasePatchSubscription(): PatchSubscription {
+ return { license: "" };
+}
+
+export const PatchSubscription = {
+ encode(message: PatchSubscription, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.license !== "") {
+ writer.uint32(10).string(message.license);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): PatchSubscription {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBasePatchSubscription();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag != 10) {
+ break;
+ }
+
+ message.license = reader.string();
+ continue;
+ }
+ if ((tag & 7) == 4 || tag == 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): PatchSubscription {
+ return { license: isSet(object.license) ? String(object.license) : "" };
+ },
+
+ toJSON(message: PatchSubscription): unknown {
+ const obj: any = {};
+ message.license !== undefined && (obj.license = message.license);
+ return obj;
+ },
+
+ create(base?: DeepPartial<PatchSubscription>): PatchSubscription {
+ return PatchSubscription.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<PatchSubscription>): PatchSubscription {
+ const message = createBasePatchSubscription();
+ message.license = object.license ?? "";
+ return message;
+ },
+};
+
+function createBaseTrialSubscription(): TrialSubscription {
+ return { plan: 0, days: 0, seat: 0, instanceCount: 0 };
+}
+
+export const TrialSubscription = {
+ encode(message: TrialSubscription, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.plan !== 0) {
+ writer.uint32(8).int32(message.plan);
+ }
+ if (message.days !== 0) {
+ writer.uint32(16).int32(message.days);
+ }
+ if (message.seat !== 0) {
+ writer.uint32(24).int32(message.seat);
+ }
+ if (message.instanceCount !== 0) {
+ writer.uint32(32).int32(message.instanceCount);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): TrialSubscription {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseTrialSubscription();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag != 8) {
+ break;
+ }
+
+ message.plan = reader.int32() as any;
+ continue;
+ case 2:
+ if (tag != 16) {
+ break;
+ }
+
+ message.days = reader.int32();
+ continue;
+ case 3:
+ if (tag != 24) {
+ break;
+ }
+
+ message.seat = reader.int32();
+ continue;
+ case 4:
+ if (tag != 32) {
+ break;
+ }
+
+ message.instanceCount = reader.int32();
+ continue;
+ }
+ if ((tag & 7) == 4 || tag == 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): TrialSubscription {
+ return {
+ plan: isSet(object.plan) ? planTypeFromJSON(object.plan) : 0,
+ days: isSet(object.days) ? Number(object.days) : 0,
+ seat: isSet(object.seat) ? Number(object.seat) : 0,
+ instanceCount: isSet(object.instanceCount) ? Number(object.instanceCount) : 0,
+ };
+ },
+
+ toJSON(message: TrialSubscription): unknown {
+ const obj: any = {};
+ message.plan !== undefined && (obj.plan = planTypeToJSON(message.plan));
+ message.days !== undefined && (obj.days = Math.round(message.days));
+ message.seat !== undefined && (obj.seat = Math.round(message.seat));
+ message.instanceCount !== undefined && (obj.instanceCount = Math.round(message.instanceCount));
+ return obj;
+ },
+
+ create(base?: DeepPartial<TrialSubscription>): TrialSubscription {
+ return TrialSubscription.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<TrialSubscription>): TrialSubscription {
+ const message = createBaseTrialSubscription();
+ message.plan = object.plan ?? 0;
+ message.days = object.days ?? 0;
+ message.seat = object.seat ?? 0;
+ message.instanceCount = object.instanceCount ?? 0;
+ return message;
+ },
+};
+
+function createBaseSubscription(): Subscription {
+ return {
+ seat: 0,
+ instanceCount: 0,
+ expiresTime: undefined,
+ startedTime: undefined,
+ plan: 0,
+ trialing: false,
+ orgId: "",
+ orgName: "",
+ };
+}
+
+export const Subscription = {
+ encode(message: Subscription, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.seat !== 0) {
+ writer.uint32(8).int32(message.seat);
+ }
+ if (message.instanceCount !== 0) {
+ writer.uint32(16).int32(message.instanceCount);
+ }
+ if (message.expiresTime !== undefined) {
+ Timestamp.encode(toTimestamp(message.expiresTime), writer.uint32(26).fork()).ldelim();
+ }
+ if (message.startedTime !== undefined) {
+ Timestamp.encode(toTimestamp(message.startedTime), writer.uint32(34).fork()).ldelim();
+ }
+ if (message.plan !== 0) {
+ writer.uint32(40).int32(message.plan);
+ }
+ if (message.trialing === true) {
+ writer.uint32(48).bool(message.trialing);
+ }
+ if (message.orgId !== "") {
+ writer.uint32(58).string(message.orgId);
+ }
+ if (message.orgName !== "") {
+ writer.uint32(66).string(message.orgName);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): Subscription {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseSubscription();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag != 8) {
+ break;
+ }
+
+ message.seat = reader.int32();
+ continue;
+ case 2:
+ if (tag != 16) {
+ break;
+ }
+
+ message.instanceCount = reader.int32();
+ continue;
+ case 3:
+ if (tag != 26) {
+ break;
+ }
+
+ message.expiresTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
+ continue;
+ case 4:
+ if (tag != 34) {
+ break;
+ }
+
+ message.startedTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
+ continue;
+ case 5:
+ if (tag != 40) {
+ break;
+ }
+
+ message.plan = reader.int32() as any;
+ continue;
+ case 6:
+ if (tag != 48) {
+ break;
+ }
+
+ message.trialing = reader.bool();
+ continue;
+ case 7:
+ if (tag != 58) {
+ break;
+ }
+
+ message.orgId = reader.string();
+ continue;
+ case 8:
+ if (tag != 66) {
+ break;
+ }
+
+ message.orgName = reader.string();
+ continue;
+ }
+ if ((tag & 7) == 4 || tag == 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): Subscription {
+ return {
+ seat: isSet(object.seat) ? Number(object.seat) : 0,
+ instanceCount: isSet(object.instanceCount) ? Number(object.instanceCount) : 0,
+ expiresTime: isSet(object.expiresTime) ? fromJsonTimestamp(object.expiresTime) : undefined,
+ startedTime: isSet(object.startedTime) ? fromJsonTimestamp(object.startedTime) : undefined,
+ plan: isSet(object.plan) ? planTypeFromJSON(object.plan) : 0,
+ trialing: isSet(object.trialing) ? Boolean(object.trialing) : false,
+ orgId: isSet(object.orgId) ? String(object.orgId) : "",
+ orgName: isSet(object.orgName) ? String(object.orgName) : "",
+ };
+ },
+
+ toJSON(message: Subscription): unknown {
+ const obj: any = {};
+ message.seat !== undefined && (obj.seat = Math.round(message.seat));
+ message.instanceCount !== undefined && (obj.instanceCount = Math.round(message.instanceCount));
+ message.expiresTime !== undefined && (obj.expiresTime = message.expiresTime.toISOString());
+ message.startedTime !== undefined && (obj.startedTime = message.startedTime.toISOString());
+ message.plan !== undefined && (obj.plan = planTypeToJSON(message.plan));
+ message.trialing !== undefined && (obj.trialing = message.trialing);
+ message.orgId !== undefined && (obj.orgId = message.orgId);
+ message.orgName !== undefined && (obj.orgName = message.orgName);
+ return obj;
+ },
+
+ create(base?: DeepPartial<Subscription>): Subscription {
+ return Subscription.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<Subscription>): Subscription {
+ const message = createBaseSubscription();
+ message.seat = object.seat ?? 0;
+ message.instanceCount = object.instanceCount ?? 0;
+ message.expiresTime = object.expiresTime ?? undefined;
+ message.startedTime = object.startedTime ?? undefined;
+ message.plan = object.plan ?? 0;
+ message.trialing = object.trialing ?? false;
+ message.orgId = object.orgId ?? "";
+ message.orgName = object.orgName ?? "";
+ return message;
+ },
+};
+
+export type SubscriptionServiceDefinition = typeof SubscriptionServiceDefinition;
+export const SubscriptionServiceDefinition = {
+ name: "SubscriptionService",
+ fullName: "bytebase.v1.SubscriptionService",
+ methods: {
+ getSubscription: {
+ name: "GetSubscription",
+ requestType: GetSubscriptionRequest,
+ requestStream: false,
+ responseType: Subscription,
+ responseStream: false,
+ options: {
+ _unknownFields: {
+ 8410: [new Uint8Array([0])],
+ 578365826: [
+ new Uint8Array([18, 18, 16, 47, 118, 49, 47, 115, 117, 98, 115, 99, 114, 105, 112, 116, 105, 111, 110]),
+ ],
+ },
+ },
+ },
+ updateSubscription: {
+ name: "UpdateSubscription",
+ requestType: UpdateSubscriptionRequest,
+ requestStream: false,
+ responseType: Subscription,
+ responseStream: false,
+ options: {
+ _unknownFields: {
+ 8410: [new Uint8Array([5, 112, 97, 116, 99, 104])],
+ 578365826: [
+ new Uint8Array([
+ 25,
+ 58,
+ 5,
+ 112,
+ 97,
+ 116,
+ 99,
+ 104,
+ 50,
+ 16,
+ 47,
+ 118,
+ 49,
+ 47,
+ 115,
+ 117,
+ 98,
+ 115,
+ 99,
+ 114,
+ 105,
+ 112,
+ 116,
+ 105,
+ 111,
+ 110,
+ ]),
+ ],
+ },
+ },
+ },
+ trialSubscription: {
+ name: "TrialSubscription",
+ requestType: TrialSubscriptionRequest,
+ requestStream: false,
+ responseType: Subscription,
+ responseStream: false,
+ options: {
+ _unknownFields: {
+ 8410: [new Uint8Array([5, 116, 114, 105, 97, 108])],
+ 578365826: [
+ new Uint8Array([
+ 31,
+ 58,
+ 5,
+ 116,
+ 114,
+ 105,
+ 97,
+ 108,
+ 34,
+ 22,
+ 47,
+ 118,
+ 49,
+ 47,
+ 115,
+ 117,
+ 98,
+ 115,
+ 99,
+ 114,
+ 105,
+ 112,
+ 116,
+ 105,
+ 111,
+ 110,
+ 47,
+ 116,
+ 114,
+ 105,
+ 97,
+ 108,
+ ]),
+ ],
+ },
+ },
+ },
+ },
+} as const;
+
+export interface SubscriptionServiceImplementation<CallContextExt = {}> {
+ getSubscription(
+ request: GetSubscriptionRequest,
+ context: CallContext & CallContextExt,
+ ): Promise<DeepPartial<Subscription>>;
+ updateSubscription(
+ request: UpdateSubscriptionRequest,
+ context: CallContext & CallContextExt,
+ ): Promise<DeepPartial<Subscription>>;
+ trialSubscription(
+ request: TrialSubscriptionRequest,
+ context: CallContext & CallContextExt,
+ ): Promise<DeepPartial<Subscription>>;
+}
+
+export interface SubscriptionServiceClient<CallOptionsExt = {}> {
+ getSubscription(
+ request: DeepPartial<GetSubscriptionRequest>,
+ options?: CallOptions & CallOptionsExt,
+ ): Promise<Subscription>;
+ updateSubscription(
+ request: DeepPartial<UpdateSubscriptionRequest>,
+ options?: CallOptions & CallOptionsExt,
+ ): Promise<Subscription>;
+ trialSubscription(
+ request: DeepPartial<TrialSubscriptionRequest>,
+ options?: CallOptions & CallOptionsExt,
+ ): Promise<Subscription>;
+}
+
+type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
+
+export type DeepPartial<T> = T extends Builtin ? T
+ : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
+ : Partial<T>;
+
+function toTimestamp(date: Date): Timestamp {
+ const seconds = date.getTime() / 1_000;
+ const nanos = (date.getTime() % 1_000) * 1_000_000;
+ return { seconds, nanos };
+}
+
+function fromTimestamp(t: Timestamp): Date {
+ let millis = t.seconds * 1_000;
+ millis += t.nanos / 1_000_000;
+ return new Date(millis);
+}
+
+function fromJsonTimestamp(o: any): Date {
+ if (o instanceof Date) {
+ return o;
+ } else if (typeof o === "string") {
+ return new Date(o);
+ } else {
+ return fromTimestamp(Timestamp.fromJSON(o));
+ }
+}
+
+function isSet(value: any): boolean {
+ return value !== null && value !== undefined;
+}
diff --git a/frontend/src/types/sqlReview.ts b/frontend/src/types/sqlReview.ts
index 05d30ed0eb..7757563770 100644
--- a/frontend/src/types/sqlReview.ts
+++ b/frontend/src/types/sqlReview.ts
@@ -2,7 +2,7 @@ import { useI18n } from "vue-i18n";
import { PolicyId } from "./id";
import { RowStatus } from "./common";
import { Environment } from "./environment";
-import { PlanType } from "./plan";
+import { PlanType } from "@/types/proto/v1/subscription_service";
import sqlReviewSchema from "./sql-review-schema.yaml";
import sqlReviewSampleTemplate from "./sql-review.sample.yaml";
import sqlReviewProdTemplate from "./sql-review.prod.yaml";
diff --git a/frontend/src/types/store.ts b/frontend/src/types/store.ts
index 682b605b87..db1233d66b 100644
--- a/frontend/src/types/store.ts
+++ b/frontend/src/types/store.ts
@@ -11,7 +11,6 @@ import {
PolicyResourceType,
} from ".";
import { Activity } from "./activity";
-import { ServerInfo } from "./actuator";
import { Backup, BackupSetting } from "./backup";
import { Bookmark } from "./bookmark";
import { Command } from "./common";
@@ -36,7 +35,6 @@ import { Issue } from "./issue";
import { IssueSubscriber } from "./issueSubscriber";
import { Member } from "./member";
import { Notification } from "./notification";
-import { PlanType } from "./plan";
import { Principal } from "./principal";
import { Project } from "./project";
import { ProjectWebhook } from "./projectWebhook";
@@ -48,9 +46,10 @@ import { ReleaseInfo } from "./actuator";
import type { DebugLog } from "@/types/debug";
import type { AuditLog } from "@/types/auditLog";
import { DatabaseMetadata } from "./proto/store/database";
+import { ActuatorInfo } from "@/types/proto/v1/actuator_service";
export interface ActuatorState {
- serverInfo?: ServerInfo;
+ serverInfo?: ActuatorInfo;
releaseInfo: RemovableRef<ReleaseInfo>;
}
@@ -62,10 +61,6 @@ export interface SettingState {
settingByName: Map<SettingName, Setting>;
}
-export interface PlanState {
- plan: PlanType;
-}
-
export interface MemberState {
memberList: Member[];
}
diff --git a/frontend/src/types/subscription.ts b/frontend/src/types/subscription.ts
index aaa130466c..3713a6e3bd 100644
--- a/frontend/src/types/subscription.ts
+++ b/frontend/src/types/subscription.ts
@@ -1,13 +1,5 @@
-import { PlanType, FeatureType } from "./plan";
-
-export interface Subscription {
- instanceCount: number;
- seat: number;
- expiresTs: number;
- startedTs: number;
- plan: PlanType;
- trialing: boolean;
-}
+import { FeatureType } from "./plan";
+import { Subscription } from "@/types/proto/v1/subscription_service";
export interface SubscriptionState {
featureMatrix: Map<FeatureType, boolean[]>;
diff --git a/frontend/src/views/BannerSubscription.vue b/frontend/src/views/BannerSubscription.vue
index c953a1ea54..a970695b25 100644
--- a/frontend/src/views/BannerSubscription.vue
+++ b/frontend/src/views/BannerSubscription.vue
@@ -43,7 +43,7 @@
<script lang="ts">
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import { PlanType } from "../types";
+import { PlanType } from "@/types/proto/v1/subscription_service";
import { useSubscriptionStore } from "@/store";
import { storeToRefs } from "pinia";
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 21a73ab002..e3262f7a55 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -226,7 +226,7 @@ import {
useInboxStore,
} from "@/store";
import { storeToRefs } from "pinia";
-import { PlanType } from "@/types";
+import { PlanType } from "@/types/proto/v1/subscription_service";
interface LocalState {
showMobileMenu: boolean;
diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue
index 2eedf0a0fe..9b1559f371 100644
--- a/frontend/src/views/Home.vue
+++ b/frontend/src/views/Home.vue
@@ -110,7 +110,7 @@
$t('subscription.trial-start-modal.title', {
plan: $t(
`subscription.plan.${planTypeToString(
- subscriptionStore.subscription.plan
+ subscriptionStore.currentPlan
).toLowerCase()}.title`
),
})
@@ -128,7 +128,7 @@
{{
$t(
`subscription.plan.${planTypeToString(
- subscriptionStore.subscription.plan
+ subscriptionStore.currentPlan
).toLowerCase()}.title`
)
}}
@@ -173,7 +173,7 @@ import { useRoute, useRouter } from "vue-router";
import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";
import { IssueTable } from "../components/Issue";
import { activeEnvironment } from "../utils";
-import { Environment, Issue, planTypeToString, PlanType } from "../types";
+import { Environment, Issue, planTypeToString } from "../types";
import {
useCurrentUser,
useEnvironmentStore,
@@ -181,6 +181,7 @@ import {
useOnboardingStateStore,
} from "@/store";
import PagedIssueTable from "@/components/Issue/PagedIssueTable.vue";
+import { PlanType } from "@/types/proto/v1/subscription_service";
interface LocalState {
searchText: string;
diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vue
index bc7e6cef06..0a4bb5bd52 100644
--- a/frontend/src/views/SettingWorkspaceSubscription.vue
+++ b/frontend/src/views/SettingWorkspaceSubscription.vue
@@ -94,7 +94,7 @@
import { computed, defineComponent, reactive } from "vue";
import { useI18n } from "vue-i18n";
import PricingTable from "../components/PricingTable/";
-import { PlanType } from "../types";
+import { PlanType } from "@/types/proto/v1/subscription_service";
import {
pushNotification,
useCurrentUser,
diff --git a/frontend/src/views/auth/Signup.vue b/frontend/src/views/auth/Signup.vue
index 235d0c3300..66b6a6b96a 100644
--- a/frontend/src/views/auth/Signup.vue
+++ b/frontend/src/views/auth/Signup.vue
@@ -233,9 +233,10 @@ import {
useOnboardingStateStore,
useSubscriptionStore,
} from "@/store";
-import { SignupInfo, PlanType, TEXT_VALIDATION_DELAY } from "@/types";
+import { SignupInfo, TEXT_VALIDATION_DELAY } from "@/types";
import { isValidEmail } from "@/utils";
import AuthFooter from "./AuthFooter.vue";
+import { PlanType } from "@/types/proto/v1/subscription_service";
interface LocalState {
email: string;
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 1d7b5c0f76..5626cfa9a7 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -311,6 +311,18 @@
- [SQLService](#bytebase-v1-SQLService)
+- [v1/subscription_service.proto](#v1_subscription_service-proto)
+ - [GetSubscriptionRequest](#bytebase-v1-GetSubscriptionRequest)
+ - [PatchSubscription](#bytebase-v1-PatchSubscription)
+ - [Subscription](#bytebase-v1-Subscription)
+ - [TrialSubscription](#bytebase-v1-TrialSubscription)
+ - [TrialSubscriptionRequest](#bytebase-v1-TrialSubscriptionRequest)
+ - [UpdateSubscriptionRequest](#bytebase-v1-UpdateSubscriptionRequest)
+
+ - [PlanType](#bytebase-v1-PlanType)
+
+ - [SubscriptionService](#bytebase-v1-SubscriptionService)
+
- [Scalar Value Types](#scalar-value-types)
@@ -4630,6 +4642,143 @@ The data in setting value.
+<a name="v1_subscription_service-proto"></a>
+<p align="right"><a href="#top">Top</a></p>
+
+## v1/subscription_service.proto
+
+
+
+<a name="bytebase-v1-GetSubscriptionRequest"></a>
+
+### GetSubscriptionRequest
+
+
+
+
+
+
+
+<a name="bytebase-v1-PatchSubscription"></a>
+
+### PatchSubscription
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| license | [string](#string) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-Subscription"></a>
+
+### Subscription
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| seat | [int32](#int32) | | |
+| instance_count | [int32](#int32) | | |
+| expires_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
+| started_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
+| plan | [PlanType](#bytebase-v1-PlanType) | | |
+| trialing | [bool](#bool) | | |
+| org_id | [string](#string) | | |
+| org_name | [string](#string) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-TrialSubscription"></a>
+
+### TrialSubscription
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| plan | [PlanType](#bytebase-v1-PlanType) | | |
+| days | [int32](#int32) | | |
+| seat | [int32](#int32) | | |
+| instance_count | [int32](#int32) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-TrialSubscriptionRequest"></a>
+
+### TrialSubscriptionRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| trial | [TrialSubscription](#bytebase-v1-TrialSubscription) | | |
+
+
+
+
+
+
+<a name="bytebase-v1-UpdateSubscriptionRequest"></a>
+
+### UpdateSubscriptionRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| patch | [PatchSubscription](#bytebase-v1-PatchSubscription) | | |
+
+
+
+
+
+
+
+
+<a name="bytebase-v1-PlanType"></a>
+
+### PlanType
+
+
+| Name | Number | Description |
+| ---- | ------ | ----------- |
+| PLAN_TYPE_UNSPECIFIED | 0 | |
+| FREE | 1 | |
+| TEAM | 2 | |
+| ENTERPRISE | 3 | |
+
+
+
+
+
+
+
+<a name="bytebase-v1-SubscriptionService"></a>
+
+### SubscriptionService
+
+
+| Method Name | Request Type | Response Type | Description |
+| ----------- | ------------ | ------------- | ------------|
+| GetSubscription | [GetSubscriptionRequest](#bytebase-v1-GetSubscriptionRequest) | [Subscription](#bytebase-v1-Subscription) | |
+| UpdateSubscription | [UpdateSubscriptionRequest](#bytebase-v1-UpdateSubscriptionRequest) | [Subscription](#bytebase-v1-Subscription) | |
+| TrialSubscription | [TrialSubscriptionRequest](#bytebase-v1-TrialSubscriptionRequest) | [Subscription](#bytebase-v1-Subscription) | |
+
+
+
+
+
## Scalar Value Types
| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby |
diff --git a/proto/generated-go/v1/subscription_service.pb.go b/proto/generated-go/v1/subscription_service.pb.go
new file mode 100644
index 0000000000..efb9bb45c2
--- /dev/null
+++ b/proto/generated-go/v1/subscription_service.pb.go
@@ -0,0 +1,669 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.29.0
+// protoc (unknown)
+// source: v1/subscription_service.proto
+
+package v1
+
+import (
+ _ "google.golang.org/genproto/googleapis/api/annotations"
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ _ "google.golang.org/protobuf/types/known/emptypb"
+ timestamppb "google.golang.org/protobuf/types/known/timestamppb"
+ reflect "reflect"
+ sync "sync"
+)
+
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type PlanType int32
+
+const (
+ PlanType_PLAN_TYPE_UNSPECIFIED PlanType = 0
+ PlanType_FREE PlanType = 1
+ PlanType_TEAM PlanType = 2
+ PlanType_ENTERPRISE PlanType = 3
+)
+
+// Enum value maps for PlanType.
+var (
+ PlanType_name = map[int32]string{
+ 0: "PLAN_TYPE_UNSPECIFIED",
+ 1: "FREE",
+ 2: "TEAM",
+ 3: "ENTERPRISE",
+ }
+ PlanType_value = map[string]int32{
+ "PLAN_TYPE_UNSPECIFIED": 0,
+ "FREE": 1,
+ "TEAM": 2,
+ "ENTERPRISE": 3,
+ }
+)
+
+func (x PlanType) Enum() *PlanType {
+ p := new(PlanType)
+ *p = x
+ return p
+}
+
+func (x PlanType) String() string {
+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
+}
+
+func (PlanType) Descriptor() protoreflect.EnumDescriptor {
+ return file_v1_subscription_service_proto_enumTypes[0].Descriptor()
+}
+
+func (PlanType) Type() protoreflect.EnumType {
+ return &file_v1_subscription_service_proto_enumTypes[0]
+}
+
+func (x PlanType) Number() protoreflect.EnumNumber {
+ return protoreflect.EnumNumber(x)
+}
+
+// Deprecated: Use PlanType.Descriptor instead.
+func (PlanType) EnumDescriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{0}
+}
+
+type GetSubscriptionRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+}
+
+func (x *GetSubscriptionRequest) Reset() {
+ *x = GetSubscriptionRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_subscription_service_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *GetSubscriptionRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GetSubscriptionRequest) ProtoMessage() {}
+
+func (x *GetSubscriptionRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use GetSubscriptionRequest.ProtoReflect.Descriptor instead.
+func (*GetSubscriptionRequest) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{0}
+}
+
+type UpdateSubscriptionRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Patch *PatchSubscription `protobuf:"bytes,1,opt,name=patch,proto3" json:"patch,omitempty"`
+}
+
+func (x *UpdateSubscriptionRequest) Reset() {
+ *x = UpdateSubscriptionRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_subscription_service_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *UpdateSubscriptionRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*UpdateSubscriptionRequest) ProtoMessage() {}
+
+func (x *UpdateSubscriptionRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use UpdateSubscriptionRequest.ProtoReflect.Descriptor instead.
+func (*UpdateSubscriptionRequest) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *UpdateSubscriptionRequest) GetPatch() *PatchSubscription {
+ if x != nil {
+ return x.Patch
+ }
+ return nil
+}
+
+type TrialSubscriptionRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Trial *TrialSubscription `protobuf:"bytes,1,opt,name=trial,proto3" json:"trial,omitempty"`
+}
+
+func (x *TrialSubscriptionRequest) Reset() {
+ *x = TrialSubscriptionRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_subscription_service_proto_msgTypes[2]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *TrialSubscriptionRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*TrialSubscriptionRequest) ProtoMessage() {}
+
+func (x *TrialSubscriptionRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[2]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use TrialSubscriptionRequest.ProtoReflect.Descriptor instead.
+func (*TrialSubscriptionRequest) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *TrialSubscriptionRequest) GetTrial() *TrialSubscription {
+ if x != nil {
+ return x.Trial
+ }
+ return nil
+}
+
+type PatchSubscription struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ License string `protobuf:"bytes,1,opt,name=license,proto3" json:"license,omitempty"`
+}
+
+func (x *PatchSubscription) Reset() {
+ *x = PatchSubscription{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_subscription_service_proto_msgTypes[3]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *PatchSubscription) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PatchSubscription) ProtoMessage() {}
+
+func (x *PatchSubscription) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[3]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PatchSubscription.ProtoReflect.Descriptor instead.
+func (*PatchSubscription) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *PatchSubscription) GetLicense() string {
+ if x != nil {
+ return x.License
+ }
+ return ""
+}
+
+type TrialSubscription struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Plan PlanType `protobuf:"varint,1,opt,name=plan,proto3,enum=bytebase.v1.PlanType" json:"plan,omitempty"`
+ Days int32 `protobuf:"varint,2,opt,name=days,proto3" json:"days,omitempty"`
+ Seat int32 `protobuf:"varint,3,opt,name=seat,proto3" json:"seat,omitempty"`
+ InstanceCount int32 `protobuf:"varint,4,opt,name=instance_count,json=instanceCount,proto3" json:"instance_count,omitempty"`
+}
+
+func (x *TrialSubscription) Reset() {
+ *x = TrialSubscription{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_subscription_service_proto_msgTypes[4]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *TrialSubscription) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*TrialSubscription) ProtoMessage() {}
+
+func (x *TrialSubscription) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[4]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use TrialSubscription.ProtoReflect.Descriptor instead.
+func (*TrialSubscription) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *TrialSubscription) GetPlan() PlanType {
+ if x != nil {
+ return x.Plan
+ }
+ return PlanType_PLAN_TYPE_UNSPECIFIED
+}
+
+func (x *TrialSubscription) GetDays() int32 {
+ if x != nil {
+ return x.Days
+ }
+ return 0
+}
+
+func (x *TrialSubscription) GetSeat() int32 {
+ if x != nil {
+ return x.Seat
+ }
+ return 0
+}
+
+func (x *TrialSubscription) GetInstanceCount() int32 {
+ if x != nil {
+ return x.InstanceCount
+ }
+ return 0
+}
+
+type Subscription struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Seat int32 `protobuf:"varint,1,opt,name=seat,proto3" json:"seat,omitempty"`
+ InstanceCount int32 `protobuf:"varint,2,opt,name=instance_count,json=instanceCount,proto3" json:"instance_count,omitempty"`
+ ExpiresTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=expires_time,json=expiresTime,proto3" json:"expires_time,omitempty"`
+ StartedTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=started_time,json=startedTime,proto3" json:"started_time,omitempty"`
+ Plan PlanType `protobuf:"varint,5,opt,name=plan,proto3,enum=bytebase.v1.PlanType" json:"plan,omitempty"`
+ Trialing bool `protobuf:"varint,6,opt,name=trialing,proto3" json:"trialing,omitempty"`
+ OrgId string `protobuf:"bytes,7,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
+ OrgName string `protobuf:"bytes,8,opt,name=org_name,json=orgName,proto3" json:"org_name,omitempty"`
+}
+
+func (x *Subscription) Reset() {
+ *x = Subscription{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_subscription_service_proto_msgTypes[5]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *Subscription) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Subscription) ProtoMessage() {}
+
+func (x *Subscription) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_subscription_service_proto_msgTypes[5]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use Subscription.ProtoReflect.Descriptor instead.
+func (*Subscription) Descriptor() ([]byte, []int) {
+ return file_v1_subscription_service_proto_rawDescGZIP(), []int{5}
+}
+
+func (x *Subscription) GetSeat() int32 {
+ if x != nil {
+ return x.Seat
+ }
+ return 0
+}
+
+func (x *Subscription) GetInstanceCount() int32 {
+ if x != nil {
+ return x.InstanceCount
+ }
+ return 0
+}
+
+func (x *Subscription) GetExpiresTime() *timestamppb.Timestamp {
+ if x != nil {
+ return x.ExpiresTime
+ }
+ return nil
+}
+
+func (x *Subscription) GetStartedTime() *timestamppb.Timestamp {
+ if x != nil {
+ return x.StartedTime
+ }
+ return nil
+}
+
+func (x *Subscription) GetPlan() PlanType {
+ if x != nil {
+ return x.Plan
+ }
+ return PlanType_PLAN_TYPE_UNSPECIFIED
+}
+
+func (x *Subscription) GetTrialing() bool {
+ if x != nil {
+ return x.Trialing
+ }
+ return false
+}
+
+func (x *Subscription) GetOrgId() string {
+ if x != nil {
+ return x.OrgId
+ }
+ return ""
+}
+
+func (x *Subscription) GetOrgName() string {
+ if x != nil {
+ return x.OrgName
+ }
+ return ""
+}
+
+var File_v1_subscription_service_proto protoreflect.FileDescriptor
+
+var file_v1_subscription_service_proto_rawDesc = []byte{
+ 0x0a, 0x1d, 0x76, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
+ 0x6e, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
+ 0x0b, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f,
+ 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67,
+ 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72,
+ 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f,
+ 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f,
+ 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
+ 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f,
+ 0x74, 0x6f, 0x22, 0x18, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
+ 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x51, 0x0a, 0x19,
+ 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
+ 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x05, 0x70, 0x61, 0x74,
+ 0x63, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x53, 0x75, 0x62, 0x73,
+ 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x22,
+ 0x50, 0x0a, 0x18, 0x54, 0x72, 0x69, 0x61, 0x6c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70,
+ 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x05, 0x74,
+ 0x72, 0x69, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x79, 0x74,
+ 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x69, 0x61, 0x6c, 0x53, 0x75,
+ 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x74, 0x72, 0x69, 0x61,
+ 0x6c, 0x22, 0x2d, 0x0a, 0x11, 0x50, 0x61, 0x74, 0x63, 0x68, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
+ 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73,
+ 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65,
+ 0x22, 0x8d, 0x01, 0x0a, 0x11, 0x54, 0x72, 0x69, 0x61, 0x6c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
+ 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x18, 0x01,
+ 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
+ 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x70, 0x6c, 0x61,
+ 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x79, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
+ 0x04, 0x64, 0x61, 0x79, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x61, 0x74, 0x18, 0x03, 0x20,
+ 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x65, 0x61, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x73,
+ 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28,
+ 0x05, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74,
+ 0x22, 0xe8, 0x02, 0x0a, 0x0c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
+ 0x6e, 0x12, 0x17, 0x0a, 0x04, 0x73, 0x65, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x42,
+ 0x03, 0xe0, 0x41, 0x03, 0x52, 0x04, 0x73, 0x65, 0x61, 0x74, 0x12, 0x2a, 0x0a, 0x0e, 0x69, 0x6e,
+ 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01,
+ 0x28, 0x05, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63,
+ 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65,
+ 0x73, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67,
+ 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54,
+ 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0b, 0x65,
+ 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x42, 0x0a, 0x0c, 0x73, 0x74,
+ 0x61, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b,
+ 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
+ 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x03, 0xe0, 0x41,
+ 0x03, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2e,
+ 0x0a, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x62,
+ 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x6e, 0x54,
+ 0x79, 0x70, 0x65, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x04, 0x70, 0x6c, 0x61, 0x6e, 0x12, 0x1f,
+ 0x0a, 0x08, 0x74, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08,
+ 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x08, 0x74, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x6e, 0x67, 0x12,
+ 0x1a, 0x0a, 0x06, 0x6f, 0x72, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42,
+ 0x03, 0xe0, 0x41, 0x03, 0x52, 0x05, 0x6f, 0x72, 0x67, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x08, 0x6f,
+ 0x72, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0,
+ 0x41, 0x03, 0x52, 0x07, 0x6f, 0x72, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x2a, 0x49, 0x0a, 0x08, 0x50,
+ 0x6c, 0x61, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x15, 0x50, 0x4c, 0x41, 0x4e, 0x5f,
+ 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44,
+ 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x52, 0x45, 0x45, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04,
+ 0x54, 0x45, 0x41, 0x4d, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x4e, 0x54, 0x45, 0x52, 0x50,
+ 0x52, 0x49, 0x53, 0x45, 0x10, 0x03, 0x32, 0x8f, 0x03, 0x0a, 0x13, 0x53, 0x75, 0x62, 0x73, 0x63,
+ 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6e,
+ 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
+ 0x6e, 0x12, 0x23, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52,
+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
+ 0x6e, 0x22, 0x1b, 0xda, 0x41, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76,
+ 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x80,
+ 0x01, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
+ 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
+ 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
+ 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e,
+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x73,
+ 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x27, 0xda, 0x41, 0x05, 0x70, 0x61, 0x74,
+ 0x63, 0x68, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x3a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x32,
+ 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
+ 0x6e, 0x12, 0x84, 0x01, 0x0a, 0x11, 0x54, 0x72, 0x69, 0x61, 0x6c, 0x53, 0x75, 0x62, 0x73, 0x63,
+ 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
+ 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x69, 0x61, 0x6c, 0x53, 0x75, 0x62, 0x73, 0x63,
+ 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19,
+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62,
+ 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2d, 0xda, 0x41, 0x05, 0x74, 0x72,
+ 0x69, 0x61, 0x6c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x05, 0x74, 0x72, 0x69, 0x61, 0x6c,
+ 0x22, 0x16, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
+ 0x6f, 0x6e, 0x2f, 0x74, 0x72, 0x69, 0x61, 0x6c, 0x42, 0x11, 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65,
+ 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f,
+ 0x74, 0x6f, 0x33,
+}
+
+var (
+ file_v1_subscription_service_proto_rawDescOnce sync.Once
+ file_v1_subscription_service_proto_rawDescData = file_v1_subscription_service_proto_rawDesc
+)
+
+func file_v1_subscription_service_proto_rawDescGZIP() []byte {
+ file_v1_subscription_service_proto_rawDescOnce.Do(func() {
+ file_v1_subscription_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_subscription_service_proto_rawDescData)
+ })
+ return file_v1_subscription_service_proto_rawDescData
+}
+
+var file_v1_subscription_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
+var file_v1_subscription_service_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
+var file_v1_subscription_service_proto_goTypes = []interface{}{
+ (PlanType)(0), // 0: bytebase.v1.PlanType
+ (*GetSubscriptionRequest)(nil), // 1: bytebase.v1.GetSubscriptionRequest
+ (*UpdateSubscriptionRequest)(nil), // 2: bytebase.v1.UpdateSubscriptionRequest
+ (*TrialSubscriptionRequest)(nil), // 3: bytebase.v1.TrialSubscriptionRequest
+ (*PatchSubscription)(nil), // 4: bytebase.v1.PatchSubscription
+ (*TrialSubscription)(nil), // 5: bytebase.v1.TrialSubscription
+ (*Subscription)(nil), // 6: bytebase.v1.Subscription
+ (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp
+}
+var file_v1_subscription_service_proto_depIdxs = []int32{
+ 4, // 0: bytebase.v1.UpdateSubscriptionRequest.patch:type_name -> bytebase.v1.PatchSubscription
+ 5, // 1: bytebase.v1.TrialSubscriptionRequest.trial:type_name -> bytebase.v1.TrialSubscription
+ 0, // 2: bytebase.v1.TrialSubscription.plan:type_name -> bytebase.v1.PlanType
+ 7, // 3: bytebase.v1.Subscription.expires_time:type_name -> google.protobuf.Timestamp
+ 7, // 4: bytebase.v1.Subscription.started_time:type_name -> google.protobuf.Timestamp
+ 0, // 5: bytebase.v1.Subscription.plan:type_name -> bytebase.v1.PlanType
+ 1, // 6: bytebase.v1.SubscriptionService.GetSubscription:input_type -> bytebase.v1.GetSubscriptionRequest
+ 2, // 7: bytebase.v1.SubscriptionService.UpdateSubscription:input_type -> bytebase.v1.UpdateSubscriptionRequest
+ 3, // 8: bytebase.v1.SubscriptionService.TrialSubscription:input_type -> bytebase.v1.TrialSubscriptionRequest
+ 6, // 9: bytebase.v1.SubscriptionService.GetSubscription:output_type -> bytebase.v1.Subscription
+ 6, // 10: bytebase.v1.SubscriptionService.UpdateSubscription:output_type -> bytebase.v1.Subscription
+ 6, // 11: bytebase.v1.SubscriptionService.TrialSubscription:output_type -> bytebase.v1.Subscription
+ 9, // [9:12] is the sub-list for method output_type
+ 6, // [6:9] is the sub-list for method input_type
+ 6, // [6:6] is the sub-list for extension type_name
+ 6, // [6:6] is the sub-list for extension extendee
+ 0, // [0:6] is the sub-list for field type_name
+}
+
+func init() { file_v1_subscription_service_proto_init() }
+func file_v1_subscription_service_proto_init() {
+ if File_v1_subscription_service_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_v1_subscription_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*GetSubscriptionRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_v1_subscription_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*UpdateSubscriptionRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_v1_subscription_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*TrialSubscriptionRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_v1_subscription_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*PatchSubscription); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_v1_subscription_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*TrialSubscription); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_v1_subscription_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*Subscription); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_v1_subscription_service_proto_rawDesc,
+ NumEnums: 1,
+ NumMessages: 6,
+ NumExtensions: 0,
+ NumServices: 1,
+ },
+ GoTypes: file_v1_subscription_service_proto_goTypes,
+ DependencyIndexes: file_v1_subscription_service_proto_depIdxs,
+ EnumInfos: file_v1_subscription_service_proto_enumTypes,
+ MessageInfos: file_v1_subscription_service_proto_msgTypes,
+ }.Build()
+ File_v1_subscription_service_proto = out.File
+ file_v1_subscription_service_proto_rawDesc = nil
+ file_v1_subscription_service_proto_goTypes = nil
+ file_v1_subscription_service_proto_depIdxs = nil
+}
diff --git a/proto/generated-go/v1/subscription_service.pb.gw.go b/proto/generated-go/v1/subscription_service.pb.gw.go
new file mode 100644
index 0000000000..d8fb15866e
--- /dev/null
+++ b/proto/generated-go/v1/subscription_service.pb.gw.go
@@ -0,0 +1,325 @@
+// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
+// source: v1/subscription_service.proto
+
+/*
+Package v1 is a reverse proxy.
+
+It translates gRPC into RESTful JSON APIs.
+*/
+package v1
+
+import (
+ "context"
+ "io"
+ "net/http"
+
+ "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
+ "github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/grpclog"
+ "google.golang.org/grpc/metadata"
+ "google.golang.org/grpc/status"
+ "google.golang.org/protobuf/proto"
+)
+
+// Suppress "imported and not used" errors
+var _ codes.Code
+var _ io.Reader
+var _ status.Status
+var _ = runtime.String
+var _ = utilities.NewDoubleArray
+var _ = metadata.Join
+
+func request_SubscriptionService_GetSubscription_0(ctx context.Context, marshaler runtime.Marshaler, client SubscriptionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetSubscriptionRequest
+ var metadata runtime.ServerMetadata
+
+ msg, err := client.GetSubscription(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_SubscriptionService_GetSubscription_0(ctx context.Context, marshaler runtime.Marshaler, server SubscriptionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetSubscriptionRequest
+ var metadata runtime.ServerMetadata
+
+ msg, err := server.GetSubscription(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+func request_SubscriptionService_UpdateSubscription_0(ctx context.Context, marshaler runtime.Marshaler, client SubscriptionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq UpdateSubscriptionRequest
+ var metadata runtime.ServerMetadata
+
+ newReader, berr := utilities.IOReaderFactory(req.Body)
+ if berr != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
+ }
+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Patch); err != nil && err != io.EOF {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.UpdateSubscription(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_SubscriptionService_UpdateSubscription_0(ctx context.Context, marshaler runtime.Marshaler, server SubscriptionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq UpdateSubscriptionRequest
+ var metadata runtime.ServerMetadata
+
+ newReader, berr := utilities.IOReaderFactory(req.Body)
+ if berr != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
+ }
+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Patch); err != nil && err != io.EOF {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := server.UpdateSubscription(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+func request_SubscriptionService_TrialSubscription_0(ctx context.Context, marshaler runtime.Marshaler, client SubscriptionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq TrialSubscriptionRequest
+ var metadata runtime.ServerMetadata
+
+ newReader, berr := utilities.IOReaderFactory(req.Body)
+ if berr != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
+ }
+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Trial); err != nil && err != io.EOF {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.TrialSubscription(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_SubscriptionService_TrialSubscription_0(ctx context.Context, marshaler runtime.Marshaler, server SubscriptionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq TrialSubscriptionRequest
+ var metadata runtime.ServerMetadata
+
+ newReader, berr := utilities.IOReaderFactory(req.Body)
+ if berr != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
+ }
+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Trial); err != nil && err != io.EOF {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := server.TrialSubscription(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+// RegisterSubscriptionServiceHandlerServer registers the http handlers for service SubscriptionService to "mux".
+// UnaryRPC :call SubscriptionServiceServer directly.
+// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
+// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSubscriptionServiceHandlerFromEndpoint instead.
+func RegisterSubscriptionServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SubscriptionServiceServer) error {
+
+ mux.Handle("GET", pattern_SubscriptionService_GetSubscription_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/GetSubscription", runtime.WithHTTPPathPattern("/v1/subscription"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_SubscriptionService_GetSubscription_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_SubscriptionService_GetSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("PATCH", pattern_SubscriptionService_UpdateSubscription_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/UpdateSubscription", runtime.WithHTTPPathPattern("/v1/subscription"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_SubscriptionService_UpdateSubscription_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_SubscriptionService_UpdateSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_SubscriptionService_TrialSubscription_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/TrialSubscription", runtime.WithHTTPPathPattern("/v1/subscription/trial"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_SubscriptionService_TrialSubscription_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_SubscriptionService_TrialSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+// RegisterSubscriptionServiceHandlerFromEndpoint is same as RegisterSubscriptionServiceHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterSubscriptionServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
+ conn, err := grpc.DialContext(ctx, endpoint, opts...)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err != nil {
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ return
+ }
+ go func() {
+ <-ctx.Done()
+ if cerr := conn.Close(); cerr != nil {
+ grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
+ }
+ }()
+ }()
+
+ return RegisterSubscriptionServiceHandler(ctx, mux, conn)
+}
+
+// RegisterSubscriptionServiceHandler registers the http handlers for service SubscriptionService to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterSubscriptionServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ return RegisterSubscriptionServiceHandlerClient(ctx, mux, NewSubscriptionServiceClient(conn))
+}
+
+// RegisterSubscriptionServiceHandlerClient registers the http handlers for service SubscriptionService
+// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SubscriptionServiceClient".
+// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SubscriptionServiceClient"
+// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
+// "SubscriptionServiceClient" to call the correct interceptors.
+func RegisterSubscriptionServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SubscriptionServiceClient) error {
+
+ mux.Handle("GET", pattern_SubscriptionService_GetSubscription_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/GetSubscription", runtime.WithHTTPPathPattern("/v1/subscription"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_SubscriptionService_GetSubscription_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_SubscriptionService_GetSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("PATCH", pattern_SubscriptionService_UpdateSubscription_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/UpdateSubscription", runtime.WithHTTPPathPattern("/v1/subscription"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_SubscriptionService_UpdateSubscription_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_SubscriptionService_UpdateSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("POST", pattern_SubscriptionService_TrialSubscription_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.SubscriptionService/TrialSubscription", runtime.WithHTTPPathPattern("/v1/subscription/trial"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_SubscriptionService_TrialSubscription_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_SubscriptionService_TrialSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_SubscriptionService_GetSubscription_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, ""))
+
+ pattern_SubscriptionService_UpdateSubscription_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, ""))
+
+ pattern_SubscriptionService_TrialSubscription_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "subscription", "trial"}, ""))
+)
+
+var (
+ forward_SubscriptionService_GetSubscription_0 = runtime.ForwardResponseMessage
+
+ forward_SubscriptionService_UpdateSubscription_0 = runtime.ForwardResponseMessage
+
+ forward_SubscriptionService_TrialSubscription_0 = runtime.ForwardResponseMessage
+)
diff --git a/proto/generated-go/v1/subscription_service_grpc.pb.go b/proto/generated-go/v1/subscription_service_grpc.pb.go
new file mode 100644
index 0000000000..a4b8a5ea91
--- /dev/null
+++ b/proto/generated-go/v1/subscription_service_grpc.pb.go
@@ -0,0 +1,183 @@
+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
+// versions:
+// - protoc-gen-go-grpc v1.3.0
+// - protoc (unknown)
+// source: v1/subscription_service.proto
+
+package v1
+
+import (
+ context "context"
+ grpc "google.golang.org/grpc"
+ codes "google.golang.org/grpc/codes"
+ status "google.golang.org/grpc/status"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+// Requires gRPC-Go v1.32.0 or later.
+const _ = grpc.SupportPackageIsVersion7
+
+const (
+ SubscriptionService_GetSubscription_FullMethodName = "/bytebase.v1.SubscriptionService/GetSubscription"
+ SubscriptionService_UpdateSubscription_FullMethodName = "/bytebase.v1.SubscriptionService/UpdateSubscription"
+ SubscriptionService_TrialSubscription_FullMethodName = "/bytebase.v1.SubscriptionService/TrialSubscription"
+)
+
+// SubscriptionServiceClient is the client API for SubscriptionService service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
+type SubscriptionServiceClient interface {
+ GetSubscription(ctx context.Context, in *GetSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error)
+ UpdateSubscription(ctx context.Context, in *UpdateSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error)
+ TrialSubscription(ctx context.Context, in *TrialSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error)
+}
+
+type subscriptionServiceClient struct {
+ cc grpc.ClientConnInterface
+}
+
+func NewSubscriptionServiceClient(cc grpc.ClientConnInterface) SubscriptionServiceClient {
+ return &subscriptionServiceClient{cc}
+}
+
+func (c *subscriptionServiceClient) GetSubscription(ctx context.Context, in *GetSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error) {
+ out := new(Subscription)
+ err := c.cc.Invoke(ctx, SubscriptionService_GetSubscription_FullMethodName, in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *subscriptionServiceClient) UpdateSubscription(ctx context.Context, in *UpdateSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error) {
+ out := new(Subscription)
+ err := c.cc.Invoke(ctx, SubscriptionService_UpdateSubscription_FullMethodName, in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *subscriptionServiceClient) TrialSubscription(ctx context.Context, in *TrialSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error) {
+ out := new(Subscription)
+ err := c.cc.Invoke(ctx, SubscriptionService_TrialSubscription_FullMethodName, in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// SubscriptionServiceServer is the server API for SubscriptionService service.
+// All implementations must embed UnimplementedSubscriptionServiceServer
+// for forward compatibility
+type SubscriptionServiceServer interface {
+ GetSubscription(context.Context, *GetSubscriptionRequest) (*Subscription, error)
+ UpdateSubscription(context.Context, *UpdateSubscriptionRequest) (*Subscription, error)
+ TrialSubscription(context.Context, *TrialSubscriptionRequest) (*Subscription, error)
+ mustEmbedUnimplementedSubscriptionServiceServer()
+}
+
+// UnimplementedSubscriptionServiceServer must be embedded to have forward compatible implementations.
+type UnimplementedSubscriptionServiceServer struct {
+}
+
+func (UnimplementedSubscriptionServiceServer) GetSubscription(context.Context, *GetSubscriptionRequest) (*Subscription, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method GetSubscription not implemented")
+}
+func (UnimplementedSubscriptionServiceServer) UpdateSubscription(context.Context, *UpdateSubscriptionRequest) (*Subscription, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method UpdateSubscription not implemented")
+}
+func (UnimplementedSubscriptionServiceServer) TrialSubscription(context.Context, *TrialSubscriptionRequest) (*Subscription, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method TrialSubscription not implemented")
+}
+func (UnimplementedSubscriptionServiceServer) mustEmbedUnimplementedSubscriptionServiceServer() {}
+
+// UnsafeSubscriptionServiceServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to SubscriptionServiceServer will
+// result in compilation errors.
+type UnsafeSubscriptionServiceServer interface {
+ mustEmbedUnimplementedSubscriptionServiceServer()
+}
+
+func RegisterSubscriptionServiceServer(s grpc.ServiceRegistrar, srv SubscriptionServiceServer) {
+ s.RegisterService(&SubscriptionService_ServiceDesc, srv)
+}
+
+func _SubscriptionService_GetSubscription_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(GetSubscriptionRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SubscriptionServiceServer).GetSubscription(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SubscriptionService_GetSubscription_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SubscriptionServiceServer).GetSubscription(ctx, req.(*GetSubscriptionRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _SubscriptionService_UpdateSubscription_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(UpdateSubscriptionRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SubscriptionServiceServer).UpdateSubscription(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SubscriptionService_UpdateSubscription_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SubscriptionServiceServer).UpdateSubscription(ctx, req.(*UpdateSubscriptionRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _SubscriptionService_TrialSubscription_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(TrialSubscriptionRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SubscriptionServiceServer).TrialSubscription(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SubscriptionService_TrialSubscription_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SubscriptionServiceServer).TrialSubscription(ctx, req.(*TrialSubscriptionRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+// SubscriptionService_ServiceDesc is the grpc.ServiceDesc for SubscriptionService service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var SubscriptionService_ServiceDesc = grpc.ServiceDesc{
+ ServiceName: "bytebase.v1.SubscriptionService",
+ HandlerType: (*SubscriptionServiceServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "GetSubscription",
+ Handler: _SubscriptionService_GetSubscription_Handler,
+ },
+ {
+ MethodName: "UpdateSubscription",
+ Handler: _SubscriptionService_UpdateSubscription_Handler,
+ },
+ {
+ MethodName: "TrialSubscription",
+ Handler: _SubscriptionService_TrialSubscription_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "v1/subscription_service.proto",
+}
diff --git a/proto/v1/subscription_service.proto b/proto/v1/subscription_service.proto
new file mode 100644
index 0000000000..00fa82d5e1
--- /dev/null
+++ b/proto/v1/subscription_service.proto
@@ -0,0 +1,84 @@
+syntax = "proto3";
+
+package bytebase.v1;
+
+import "google/api/annotations.proto";
+import "google/api/client.proto";
+import "google/api/field_behavior.proto";
+import "google/protobuf/empty.proto";
+import "google/protobuf/timestamp.proto";
+
+option go_package = "generated-go/v1";
+
+service SubscriptionService {
+ rpc GetSubscription(GetSubscriptionRequest) returns (Subscription) {
+ option (google.api.http) = {get: "/v1/subscription"};
+ option (google.api.method_signature) = "";
+ }
+ rpc UpdateSubscription(UpdateSubscriptionRequest) returns (Subscription) {
+ option (google.api.http) = {
+ patch: "/v1/subscription"
+ body: "patch"
+ };
+ option (google.api.method_signature) = "patch";
+ }
+ rpc TrialSubscription(TrialSubscriptionRequest) returns (Subscription) {
+ option (google.api.http) = {
+ post: "/v1/subscription/trial"
+ body: "trial"
+ };
+ option (google.api.method_signature) = "trial";
+ }
+}
+
+message GetSubscriptionRequest {}
+
+message UpdateSubscriptionRequest {
+ PatchSubscription patch = 1;
+}
+
+message TrialSubscriptionRequest {
+ TrialSubscription trial = 1;
+}
+
+enum PlanType {
+ PLAN_TYPE_UNSPECIFIED = 0;
+
+ FREE = 1;
+
+ TEAM = 2;
+
+ ENTERPRISE = 3;
+}
+
+message PatchSubscription {
+ string license = 1;
+}
+
+message TrialSubscription {
+ PlanType plan = 1;
+
+ int32 days = 2;
+
+ int32 seat = 3;
+
+ int32 instance_count = 4;
+}
+
+message Subscription {
+ int32 seat = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ int32 instance_count = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ google.protobuf.Timestamp expires_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ google.protobuf.Timestamp started_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ PlanType plan = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ bool trialing = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ string org_id = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ string org_name = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
+}
\ No newline at end of file