Skip to content

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

feat: support delete/leave workspace (#20282)

ecmadao56ab51efe029
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yaml
index f7b6f060a5..df289eeee6 100644
--- a/backend/api/mcp/gen/openapi.yaml
+++ b/backend/api/mcp/gen/openapi.yaml
@@ -7285,6 +7285,45 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.WorksheetOrganizer'
+ /bytebase.v1.WorkspaceService/DeleteWorkspace:
+ post:
+ tags:
+ - bytebase.v1.WorkspaceService
+ summary: DeleteWorkspace
+ description: |-
+ Deletes a workspace. SaaS only. Cancels any active subscription and
+ soft-deletes the workspace so all associated data becomes inaccessible.
+ Requires workspace admin permission.
+ operationId: bytebase.v1.WorkspaceService.DeleteWorkspace
+ parameters:
+ - name: Connect-Protocol-Version
+ in: header
+ required: true
+ schema:
+ $ref: '#/components/schemas/connect-protocol-version'
+ - name: Connect-Timeout-Ms
+ in: header
+ schema:
+ $ref: '#/components/schemas/connect-timeout-header'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.DeleteWorkspaceRequest'
+ required: true
+ responses:
+ default:
+ description: Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/connect.error'
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.LoginResponse'
/bytebase.v1.WorkspaceService/GetIamPolicy:
post:
tags:
@@ -7364,6 +7403,45 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.Workspace'
+ /bytebase.v1.WorkspaceService/LeaveWorkspace:
+ post:
+ tags:
+ - bytebase.v1.WorkspaceService
+ summary: LeaveWorkspace
+ description: |-
+ Removes the calling user from a workspace and switches to the next
+ available workspace. Available to any workspace member. Fails if the
+ caller is the last workspace admin.
+ operationId: bytebase.v1.WorkspaceService.LeaveWorkspace
+ parameters:
+ - name: Connect-Protocol-Version
+ in: header
+ required: true
+ schema:
+ $ref: '#/components/schemas/connect-protocol-version'
+ - name: Connect-Timeout-Ms
+ in: header
+ schema:
+ $ref: '#/components/schemas/connect-timeout-header'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.LeaveWorkspaceRequest'
+ required: true
+ responses:
+ default:
+ description: Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/connect.error'
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.LoginResponse'
/bytebase.v1.WorkspaceService/ListWorkspaces:
post:
tags:
@@ -10726,6 +10804,15 @@ components:
Format: projects/{project}/worksheets/{worksheet}
title: DeleteWorksheetRequest
additionalProperties: false
+ bytebase.v1.DeleteWorkspaceRequest:
+ type: object
+ properties:
+ name:
+ type: string
+ title: name
+ description: 'Format: workspaces/{workspace}'
+ title: DeleteWorkspaceRequest
+ additionalProperties: false
bytebase.v1.DependencyColumn:
type: object
properties:
@@ -12758,6 +12845,15 @@ components:
title: Label
additionalProperties: false
description: A label for categorizing and organizing issues.
+ bytebase.v1.LeaveWorkspaceRequest:
+ type: object
+ properties:
+ name:
+ type: string
+ title: name
+ description: 'Format: workspaces/{workspace}'
+ title: LeaveWorkspaceRequest
+ additionalProperties: false
bytebase.v1.ListAccessGrantsRequest:
type: object
properties:
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.go
index 57b1e6dc14..0a2410b070 100644
--- a/backend/api/v1/auth_service.go
+++ b/backend/api/v1/auth_service.go
@@ -9,6 +9,7 @@ import (
"encoding/hex"
"fmt"
"log/slog"
+ "net/http"
"os"
"slices"
"strings"
@@ -105,13 +106,25 @@ func (s *AuthService) Login(ctx context.Context, req *connect.Request[v1pb.Login
return nil, err
}
- // 2. Resolve workspace early so all subsequent checks can use it.
+ // 2. Reject deactivated users before any workspace provisioning.
+ if loginUser.MemberDeleted {
+ return nil, connect.NewError(connect.CodeUnauthenticated, errors.New("user has been deactivated"))
+ }
+
+ // 3. Resolve workspace early so all subsequent checks can use it.
// Login is allow_without_credential, so workspace is NOT in the context from auth middleware.
preferredWS, _ := parseOptionalWorkspace(request.Workspace)
workspaceID, err := s.resolveWorkspaceForLogin(ctx, loginUser, preferredWS)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to resolve workspace"))
}
+ // If the user has no workspace (e.g. left all workspaces), provision a new one.
+ if workspaceID == "" {
+ workspaceID, err = s.provisionWorkspaceForNewUser(ctx, loginUser.Email)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to provision workspace"))
+ }
+ }
common.SetAuditWorkspaceID(ctx, workspaceID)
// 3. Post-auth checks (deleted, domain, license)
@@ -394,21 +407,21 @@ func (s *AuthService) provisionWorkspaceForNewUser(ctx context.Context, email st
// Logout is the auth logout method.
func (s *AuthService) Logout(ctx context.Context, req *connect.Request[v1pb.LogoutRequest]) (*connect.Response[emptypb.Empty], error) {
- // Delete refresh token from database if present
- if refreshToken := auth.GetRefreshTokenFromCookie(req.Header()); refreshToken != "" {
+ resp := connect.NewResponse(&emptypb.Empty{})
+ s.clearSessionAndSetCookies(ctx, req.Header(), resp.Header(), common.GetWorkspaceIDFromContext(ctx))
+ return resp, nil
+}
+
+// clearSessionAndSetCookies deletes the refresh token and sets expired cookies on the response headers.
+func (s *AuthService) clearSessionAndSetCookies(ctx context.Context, reqHeaders http.Header, respHeaders http.Header, workspaceID string) {
+ if refreshToken := auth.GetRefreshTokenFromCookie(reqHeaders); refreshToken != "" {
if err := s.store.DeleteWebRefreshToken(ctx, auth.HashToken(refreshToken)); err != nil {
- slog.Error("failed to delete refresh token on logout", log.BBError(err))
+ slog.Error("failed to delete refresh token", log.BBError(err))
}
}
-
- resp := connect.NewResponse(&emptypb.Empty{})
-
- origin := req.Header().Get("Origin")
- // Clear access token cookie
- resp.Header().Add("Set-Cookie", auth.GetTokenCookie(ctx, s.store, s.licenseService, common.GetWorkspaceIDFromContext(ctx), origin, "").String())
- // Clear refresh token cookie
- resp.Header().Add("Set-Cookie", auth.GetRefreshTokenCookie(origin, "", 0).String())
- return resp, nil
+ origin := reqHeaders.Get("Origin")
+ respHeaders.Add("Set-Cookie", auth.GetTokenCookie(ctx, s.store, s.licenseService, workspaceID, origin, "").String())
+ respHeaders.Add("Set-Cookie", auth.GetRefreshTokenCookie(origin, "", 0).String())
}
// Refresh exchanges a refresh token for new access and refresh tokens.
@@ -1122,7 +1135,7 @@ func (s *AuthService) resolveWorkspaceForLogin(ctx context.Context, user *store.
return "", errors.Wrap(err, "failed to find workspace")
}
if ws == nil {
- return "", errors.Errorf("%q is not a member of any workspace", user.Email)
+ return "", nil
}
return ws.ResourceID, nil
default:
@@ -1216,7 +1229,13 @@ func (s *AuthService) SwitchWorkspace(ctx context.Context, req *connect.Request[
}
}
- // Generate new token with target workspace.
+ return s.switchWorkspaceInternal(ctx, user, workspaceID, request.Web, req.Header())
+}
+
+// switchWorkspaceInternal generates new tokens for the target workspace and
+// returns a LoginResponse with cookies set. Used by SwitchWorkspace,
+// LeaveWorkspace, and DeleteWorkspace.
+func (s *AuthService) switchWorkspaceInternal(ctx context.Context, user *store.UserMessage, workspaceID string, web bool, reqHeaders http.Header) (*connect.Response[v1pb.LoginResponse], error) {
token, err := s.generateLoginToken(ctx, user, workspaceID)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to generate token"))
@@ -1234,14 +1253,11 @@ func (s *AuthService) SwitchWorkspace(ctx context.Context, req *connect.Request[
slog.Error("failed to update user profile", log.BBError(err))
}
- // Build response.
response := &v1pb.LoginResponse{}
resp := connect.NewResponse(response)
- if request.Web {
- // Require a valid refresh token cookie — prevents non-web clients from
- // upgrading a short-lived bearer token into a long-lived web session.
- oldRefreshToken := auth.GetRefreshTokenFromCookie(req.Header())
+ if web {
+ oldRefreshToken := auth.GetRefreshTokenFromCookie(reqHeaders)
if oldRefreshToken == "" {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("refresh token cookie required for web workspace switch"))
}
@@ -1260,7 +1276,7 @@ func (s *AuthService) SwitchWorkspace(ctx context.Context, req *connect.Request[
sessionExpiresAt = time.Now().Add(auth.GetRefreshTokenDuration(ctx, s.store, s.licenseService, workspaceID))
}
- origin := req.Header().Get("Origin")
+ origin := reqHeaders.Get("Origin")
cookie := auth.GetTokenCookie(ctx, s.store, s.licenseService, workspaceID, origin, token)
resp.Header().Add("Set-Cookie", cookie.String())
diff --git a/backend/api/v1/workspace_service.go b/backend/api/v1/workspace_service.go
index c300bb44b8..14950cdf47 100644
--- a/backend/api/v1/workspace_service.go
+++ b/backend/api/v1/workspace_service.go
@@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
"google.golang.org/protobuf/encoding/protojson"
+ "github.com/bytebase/bytebase/backend/api/auth"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
@@ -20,6 +21,7 @@ import (
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
"github.com/bytebase/bytebase/backend/plugin/mailer"
+ stripeplugin "github.com/bytebase/bytebase/backend/plugin/stripe"
"github.com/bytebase/bytebase/backend/store"
"github.com/bytebase/bytebase/backend/utils"
)
@@ -31,6 +33,7 @@ type WorkspaceService struct {
licenseService *enterprise.LicenseService
iamManager *iam.Manager
profile *config.Profile
+ authService *AuthService
}
// NewWorkspaceService creates a new WorkspaceService.
@@ -39,12 +42,14 @@ func NewWorkspaceService(
iamManager *iam.Manager,
profile *config.Profile,
licenseService *enterprise.LicenseService,
+ authService *AuthService,
) *WorkspaceService {
return &WorkspaceService{
store: store,
iamManager: iamManager,
profile: profile,
licenseService: licenseService,
+ authService: authService,
}
}
@@ -200,6 +205,169 @@ func (s *WorkspaceService) GetIamPolicy(ctx context.Context, _ *connect.Request[
return connect.NewResponse(v1Policy), nil
}
+// DeleteWorkspace soft-deletes a workspace. SaaS only.
+// Cancels any active Stripe subscription before deleting, then switches
+// to the next available workspace and returns new auth tokens.
+func (s *WorkspaceService) DeleteWorkspace(ctx context.Context, req *connect.Request[v1pb.DeleteWorkspaceRequest]) (*connect.Response[v1pb.LoginResponse], error) {
+ if !s.profile.SaaS {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.New("workspace deletion is only supported in SaaS mode"))
+ }
+
+ user, ok := GetUserFromContext(ctx)
+ if !ok || user == nil {
+ return nil, connect.NewError(connect.CodeUnauthenticated, errors.New("user not found"))
+ }
+
+ workspaceID, err := common.GetWorkspaceID(req.Msg.Name)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInvalidArgument, err)
+ }
+ if contextWorkspaceID := common.GetWorkspaceIDFromContext(ctx); workspaceID != contextWorkspaceID {
+ return nil, connect.NewError(connect.CodePermissionDenied, errors.Errorf("cannot delete workspace %q from workspace %q", workspaceID, contextWorkspaceID))
+ }
+
+ // Cancel active Stripe subscription if any.
+ sub, err := s.store.GetSubscriptionByWorkspace(ctx, workspaceID)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to check subscription"))
+ }
+ if sub != nil && sub.Payload != nil && sub.Payload.StripeSubscriptionId != "" {
+ if _, err := stripeplugin.CancelSubscription(sub.Payload.StripeSubscriptionId, workspaceID, true); err != nil {
+ slog.Warn("failed to cancel Stripe subscription during workspace deletion",
+ slog.String("workspace", workspaceID),
+ log.BBError(err),
+ )
+ }
+ }
+
+ if err := s.store.DeleteWorkspace(ctx, workspaceID); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to delete workspace"))
+ }
+
+ // Find the next workspace and switch to it.
+ nextWS, err := s.store.FindWorkspace(ctx, &store.FindWorkspaceMessage{
+ Email: user.Email,
+ })
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to find next workspace"))
+ }
+ if nextWS == nil {
+ // No remaining workspace — clear auth cookies and return empty response.
+ // Frontend redirects to login which will provision a new workspace.
+ resp := connect.NewResponse(&v1pb.LoginResponse{})
+ s.authService.clearSessionAndSetCookies(ctx, req.Header(), resp.Header(), workspaceID)
+ return resp, nil
+ }
+
+ isWeb := auth.GetRefreshTokenFromCookie(req.Header()) != ""
+ return s.authService.switchWorkspaceInternal(ctx, user, nextWS.ResourceID, isWeb, req.Header())
+}
+
+// LeaveWorkspace removes the calling user from a workspace's IAM bindings,
+// then switches to the next available workspace.
+func (s *WorkspaceService) LeaveWorkspace(ctx context.Context, req *connect.Request[v1pb.LeaveWorkspaceRequest]) (*connect.Response[v1pb.LoginResponse], error) {
+ user, ok := GetUserFromContext(ctx)
+ if !ok || user == nil {
+ return nil, connect.NewError(connect.CodeUnauthenticated, errors.New("user not found"))
+ }
+
+ workspaceID, err := common.GetWorkspaceID(req.Msg.Name)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInvalidArgument, err)
+ }
+
+ // Verify the user is a member of the target workspace.
+ ws, err := s.store.FindWorkspace(ctx, &store.FindWorkspaceMessage{
+ WorkspaceID: &workspaceID,
+ Email: user.Email,
+ })
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to verify workspace membership"))
+ }
+ if ws == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("not a member of workspace %q", workspaceID))
+ }
+
+ memberIdentifier := common.FormatUserEmail(user.Email)
+
+ // Simulate removing the user from all direct IAM bindings and check
+ // that at least one active admin would remain. We exclude the caller
+ // from the admin list to also account for admin-via-group bindings.
+ policyMessage, err := s.store.GetWorkspaceIamPolicy(ctx, workspaceID)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to get workspace IAM policy"))
+ }
+ simulatedPolicy := &storepb.IamPolicy{}
+ for _, binding := range policyMessage.Policy.Bindings {
+ var filtered []string
+ for _, m := range binding.Members {
+ if m != memberIdentifier {
+ filtered = append(filtered, m)
+ }
+ }
+ if len(filtered) > 0 {
+ simulatedPolicy.Bindings = append(simulatedPolicy.Bindings, &storepb.Binding{
+ Role: binding.Role,
+ Members: filtered,
+ Condition: binding.Condition,
+ })
+ }
+ }
+ admins := utils.GetUsersByRoleInIAMPolicy(ctx, s.store, workspaceID, store.WorkspaceAdminRole, !s.profile.SaaS, simulatedPolicy)
+ // Filter out the caller — they may still appear as admin via group bindings
+ // that haven't been removed yet.
+ var otherAdmins []*store.UserMessage
+ for _, admin := range admins {
+ if admin.Email != user.Email {
+ otherAdmins = append(otherAdmins, admin)
+ }
+ }
+ if !containsActiveEndUser(otherAdmins) {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.New("cannot leave workspace: you are the last admin"))
+ }
+
+ // Remove the user from all groups in this workspace.
+ if err := s.store.RemoveMemberFromAllGroups(ctx, workspaceID, memberIdentifier); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to remove user from groups"))
+ }
+
+ // Remove the user from all direct IAM bindings.
+ if _, err := s.store.PatchWorkspaceIamPolicy(ctx, &store.PatchIamPolicyMessage{
+ Workspace: workspaceID,
+ Member: memberIdentifier,
+ Roles: []string{},
+ }); err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to update IAM policy"))
+ }
+
+ if err := s.iamManager.ReloadCache(ctx); err != nil {
+ return nil, err
+ }
+
+ // Only switch workspace if the user is leaving their current workspace.
+ currentWorkspaceID := common.GetWorkspaceIDFromContext(ctx)
+ if workspaceID != currentWorkspaceID {
+ // Leaving a different workspace — no token switch needed.
+ return connect.NewResponse(&v1pb.LoginResponse{}), nil
+ }
+
+ // Find the next workspace to switch to.
+ nextWS, err := s.store.FindWorkspace(ctx, &store.FindWorkspaceMessage{
+ Email: user.Email,
+ })
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to find next workspace"))
+ }
+ if nextWS == nil {
+ resp := connect.NewResponse(&v1pb.LoginResponse{})
+ s.authService.clearSessionAndSetCookies(ctx, req.Header(), resp.Header(), workspaceID)
+ return resp, nil
+ }
+
+ isWeb := auth.GetRefreshTokenFromCookie(req.Header()) != ""
+ return s.authService.switchWorkspaceInternal(ctx, user, nextWS.ResourceID, isWeb, req.Header())
+}
+
func (s *WorkspaceService) SetIamPolicy(ctx context.Context, req *connect.Request[v1pb.SetIamPolicyRequest]) (*connect.Response[v1pb.IamPolicy], error) {
request := req.Msg
diff --git a/backend/common/permission/permission.go b/backend/common/permission/permission.go
index fb6af251b1..a13db8e71b 100644
--- a/backend/common/permission/permission.go
+++ b/backend/common/permission/permission.go
@@ -153,6 +153,7 @@ const (
WorkspacesGetIamPolicy Permission = "bb.workspaces.getIamPolicy"
WorkspacesSetIamPolicy Permission = "bb.workspaces.setIamPolicy"
WorkspacesUpdate Permission = "bb.workspaces.update"
+ WorkspacesDelete Permission = "bb.workspaces.delete"
)
var allPermissions = func() []Permission {
diff --git a/backend/common/permission/permission.yaml b/backend/common/permission/permission.yaml
index 86066cb46b..e4b9670977 100644
--- a/backend/common/permission/permission.yaml
+++ b/backend/common/permission/permission.yaml
@@ -137,6 +137,7 @@ permissions:
- bb.workloadIdentities.list
- bb.workloadIdentities.undelete
- bb.workloadIdentities.update
+ - bb.workspaces.delete
- bb.workspaces.getIamPolicy
- bb.workspaces.update
- bb.workspaces.setIamPolicy
diff --git a/backend/generated-go/v1/v1connect/workspace_service.connect.go b/backend/generated-go/v1/v1connect/workspace_service.connect.go
index e101a25b0e..69c5aeb47a 100644
--- a/backend/generated-go/v1/v1connect/workspace_service.connect.go
+++ b/backend/generated-go/v1/v1connect/workspace_service.connect.go
@@ -45,6 +45,12 @@ const (
// WorkspaceServiceGetIamPolicyProcedure is the fully-qualified name of the WorkspaceService's
// GetIamPolicy RPC.
WorkspaceServiceGetIamPolicyProcedure = "/bytebase.v1.WorkspaceService/GetIamPolicy"
+ // WorkspaceServiceDeleteWorkspaceProcedure is the fully-qualified name of the WorkspaceService's
+ // DeleteWorkspace RPC.
+ WorkspaceServiceDeleteWorkspaceProcedure = "/bytebase.v1.WorkspaceService/DeleteWorkspace"
+ // WorkspaceServiceLeaveWorkspaceProcedure is the fully-qualified name of the WorkspaceService's
+ // LeaveWorkspace RPC.
+ WorkspaceServiceLeaveWorkspaceProcedure = "/bytebase.v1.WorkspaceService/LeaveWorkspace"
// WorkspaceServiceSetIamPolicyProcedure is the fully-qualified name of the WorkspaceService's
// SetIamPolicy RPC.
WorkspaceServiceSetIamPolicyProcedure = "/bytebase.v1.WorkspaceService/SetIamPolicy"
@@ -65,6 +71,14 @@ type WorkspaceServiceClient interface {
// Retrieves IAM policy for the workspace.
// Permissions required: bb.workspaces.getIamPolicy
GetIamPolicy(context.Context, *connect.Request[v1.GetIamPolicyRequest]) (*connect.Response[v1.IamPolicy], error)
+ // Deletes a workspace. SaaS only. Cancels any active subscription and
+ // soft-deletes the workspace so all associated data becomes inaccessible.
+ // Requires workspace admin permission.
+ DeleteWorkspace(context.Context, *connect.Request[v1.DeleteWorkspaceRequest]) (*connect.Response[v1.LoginResponse], error)
+ // Removes the calling user from a workspace and switches to the next
+ // available workspace. Available to any workspace member. Fails if the
+ // caller is the last workspace admin.
+ LeaveWorkspace(context.Context, *connect.Request[v1.LeaveWorkspaceRequest]) (*connect.Response[v1.LoginResponse], error)
// Sets IAM policy for the workspace.
// Permissions required: bb.workspaces.setIamPolicy
SetIamPolicy(context.Context, *connect.Request[v1.SetIamPolicyRequest]) (*connect.Response[v1.IamPolicy], error)
@@ -105,6 +119,18 @@ func NewWorkspaceServiceClient(httpClient connect.HTTPClient, baseURL string, op
connect.WithSchema(workspaceServiceMethods.ByName("GetIamPolicy")),
connect.WithClientOptions(opts...),
),
+ deleteWorkspace: connect.NewClient[v1.DeleteWorkspaceRequest, v1.LoginResponse](
+ httpClient,
+ baseURL+WorkspaceServiceDeleteWorkspaceProcedure,
+ connect.WithSchema(workspaceServiceMethods.ByName("DeleteWorkspace")),
+ connect.WithClientOptions(opts...),
+ ),
+ leaveWorkspace: connect.NewClient[v1.LeaveWorkspaceRequest, v1.LoginResponse](
+ httpClient,
+ baseURL+WorkspaceServiceLeaveWorkspaceProcedure,
+ connect.WithSchema(workspaceServiceMethods.ByName("LeaveWorkspace")),
+ connect.WithClientOptions(opts...),
+ ),
setIamPolicy: connect.NewClient[v1.SetIamPolicyRequest, v1.IamPolicy](
httpClient,
baseURL+WorkspaceServiceSetIamPolicyProcedure,
@@ -120,6 +146,8 @@ type workspaceServiceClient struct {
listWorkspaces *connect.Client[v1.ListWorkspacesRequest, v1.ListWorkspacesResponse]
updateWorkspace *connect.Client[v1.UpdateWorkspaceRequest, v1.Workspace]
getIamPolicy *connect.Client[v1.GetIamPolicyRequest, v1.IamPolicy]
+ deleteWorkspace *connect.Client[v1.DeleteWorkspaceRequest, v1.LoginResponse]
+ leaveWorkspace *connect.Client[v1.LeaveWorkspaceRequest, v1.LoginResponse]
setIamPolicy *connect.Client[v1.SetIamPolicyRequest, v1.IamPolicy]
}
@@ -143,6 +171,16 @@ func (c *workspaceServiceClient) GetIamPolicy(ctx context.Context, req *connect.
return c.getIamPolicy.CallUnary(ctx, req)
}
+// DeleteWorkspace calls bytebase.v1.WorkspaceService.DeleteWorkspace.
+func (c *workspaceServiceClient) DeleteWorkspace(ctx context.Context, req *connect.Request[v1.DeleteWorkspaceRequest]) (*connect.Response[v1.LoginResponse], error) {
+ return c.deleteWorkspace.CallUnary(ctx, req)
+}
+
+// LeaveWorkspace calls bytebase.v1.WorkspaceService.LeaveWorkspace.
+func (c *workspaceServiceClient) LeaveWorkspace(ctx context.Context, req *connect.Request[v1.LeaveWorkspaceRequest]) (*connect.Response[v1.LoginResponse], error) {
+ return c.leaveWorkspace.CallUnary(ctx, req)
+}
+
// SetIamPolicy calls bytebase.v1.WorkspaceService.SetIamPolicy.
func (c *workspaceServiceClient) SetIamPolicy(ctx context.Context, req *connect.Request[v1.SetIamPolicyRequest]) (*connect.Response[v1.IamPolicy], error) {
return c.setIamPolicy.CallUnary(ctx, req)
@@ -163,6 +201,14 @@ type WorkspaceServiceHandler interface {
// Retrieves IAM policy for the workspace.
// Permissions required: bb.workspaces.getIamPolicy
GetIamPolicy(context.Context, *connect.Request[v1.GetIamPolicyRequest]) (*connect.Response[v1.IamPolicy], error)
+ // Deletes a workspace. SaaS only. Cancels any active subscription and
+ // soft-deletes the workspace so all associated data becomes inaccessible.
+ // Requires workspace admin permission.
+ DeleteWorkspace(context.Context, *connect.Request[v1.DeleteWorkspaceRequest]) (*connect.Response[v1.LoginResponse], error)
+ // Removes the calling user from a workspace and switches to the next
+ // available workspace. Available to any workspace member. Fails if the
+ // caller is the last workspace admin.
+ LeaveWorkspace(context.Context, *connect.Request[v1.LeaveWorkspaceRequest]) (*connect.Response[v1.LoginResponse], error)
// Sets IAM policy for the workspace.
// Permissions required: bb.workspaces.setIamPolicy
SetIamPolicy(context.Context, *connect.Request[v1.SetIamPolicyRequest]) (*connect.Response[v1.IamPolicy], error)
@@ -199,6 +245,18 @@ func NewWorkspaceServiceHandler(svc WorkspaceServiceHandler, opts ...connect.Han
connect.WithSchema(workspaceServiceMethods.ByName("GetIamPolicy")),
connect.WithHandlerOptions(opts...),
)
+ workspaceServiceDeleteWorkspaceHandler := connect.NewUnaryHandler(
+ WorkspaceServiceDeleteWorkspaceProcedure,
+ svc.DeleteWorkspace,
+ connect.WithSchema(workspaceServiceMethods.ByName("DeleteWorkspace")),
+ connect.WithHandlerOptions(opts...),
+ )
+ workspaceServiceLeaveWorkspaceHandler := connect.NewUnaryHandler(
+ WorkspaceServiceLeaveWorkspaceProcedure,
+ svc.LeaveWorkspace,
+ connect.WithSchema(workspaceServiceMethods.ByName("LeaveWorkspace")),
+ connect.WithHandlerOptions(opts...),
+ )
workspaceServiceSetIamPolicyHandler := connect.NewUnaryHandler(
WorkspaceServiceSetIamPolicyProcedure,
svc.SetIamPolicy,
@@ -215,6 +273,10 @@ func NewWorkspaceServiceHandler(svc WorkspaceServiceHandler, opts ...connect.Han
workspaceServiceUpdateWorkspaceHandler.ServeHTTP(w, r)
case WorkspaceServiceGetIamPolicyProcedure:
workspaceServiceGetIamPolicyHandler.ServeHTTP(w, r)
+ case WorkspaceServiceDeleteWorkspaceProcedure:
+ workspaceServiceDeleteWorkspaceHandler.ServeHTTP(w, r)
+ case WorkspaceServiceLeaveWorkspaceProcedure:
+ workspaceServiceLeaveWorkspaceHandler.ServeHTTP(w, r)
case WorkspaceServiceSetIamPolicyProcedure:
workspaceServiceSetIamPolicyHandler.ServeHTTP(w, r)
default:
@@ -242,6 +304,14 @@ func (UnimplementedWorkspaceServiceHandler) GetIamPolicy(context.Context, *conne
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.WorkspaceService.GetIamPolicy is not implemented"))
}
+func (UnimplementedWorkspaceServiceHandler) DeleteWorkspace(context.Context, *connect.Request[v1.DeleteWorkspaceRequest]) (*connect.Response[v1.LoginResponse], error) {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.WorkspaceService.DeleteWorkspace is not implemented"))
+}
+
+func (UnimplementedWorkspaceServiceHandler) LeaveWorkspace(context.Context, *connect.Request[v1.LeaveWorkspaceRequest]) (*connect.Response[v1.LoginResponse], error) {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.WorkspaceService.LeaveWorkspace is not implemented"))
+}
+
func (UnimplementedWorkspaceServiceHandler) SetIamPolicy(context.Context, *connect.Request[v1.SetIamPolicyRequest]) (*connect.Response[v1.IamPolicy], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.WorkspaceService.SetIamPolicy is not implemented"))
}
diff --git a/backend/generated-go/v1/workspace_service.pb.go b/backend/generated-go/v1/workspace_service.pb.go
index d0f7744554..ae417a80f5 100644
--- a/backend/generated-go/v1/workspace_service.pb.go
+++ b/backend/generated-go/v1/workspace_service.pb.go
@@ -211,6 +211,51 @@ func (x *Workspace) GetLogo() string {
return ""
}
+type DeleteWorkspaceRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // Format: workspaces/{workspace}
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *DeleteWorkspaceRequest) Reset() {
+ *x = DeleteWorkspaceRequest{}
+ mi := &file_v1_workspace_service_proto_msgTypes[4]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *DeleteWorkspaceRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*DeleteWorkspaceRequest) ProtoMessage() {}
+
+func (x *DeleteWorkspaceRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_workspace_service_proto_msgTypes[4]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use DeleteWorkspaceRequest.ProtoReflect.Descriptor instead.
+func (*DeleteWorkspaceRequest) Descriptor() ([]byte, []int) {
+ return file_v1_workspace_service_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *DeleteWorkspaceRequest) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
type UpdateWorkspaceRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Workspace *Workspace `protobuf:"bytes,1,opt,name=workspace,proto3" json:"workspace,omitempty"`
@@ -221,7 +266,7 @@ type UpdateWorkspaceRequest struct {
func (x *UpdateWorkspaceRequest) Reset() {
*x = UpdateWorkspaceRequest{}
- mi := &file_v1_workspace_service_proto_msgTypes[4]
+ mi := &file_v1_workspace_service_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -233,7 +278,7 @@ func (x *UpdateWorkspaceRequest) String() string {
func (*UpdateWorkspaceRequest) ProtoMessage() {}
func (x *UpdateWorkspaceRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_workspace_service_proto_msgTypes[4]
+ mi := &file_v1_workspace_service_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -246,7 +291,7 @@ func (x *UpdateWorkspaceRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use UpdateWorkspaceRequest.ProtoReflect.Descriptor instead.
func (*UpdateWorkspaceRequest) Descriptor() ([]byte, []int) {
- return file_v1_workspace_service_proto_rawDescGZIP(), []int{4}
+ return file_v1_workspace_service_proto_rawDescGZIP(), []int{5}
}
func (x *UpdateWorkspaceRequest) GetWorkspace() *Workspace {
@@ -263,11 +308,56 @@ func (x *UpdateWorkspaceRequest) GetUpdateMask() *fieldmaskpb.FieldMask {
return nil
}
+type LeaveWorkspaceRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // Format: workspaces/{workspace}
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *LeaveWorkspaceRequest) Reset() {
+ *x = LeaveWorkspaceRequest{}
+ mi := &file_v1_workspace_service_proto_msgTypes[6]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *LeaveWorkspaceRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*LeaveWorkspaceRequest) ProtoMessage() {}
+
+func (x *LeaveWorkspaceRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_workspace_service_proto_msgTypes[6]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use LeaveWorkspaceRequest.ProtoReflect.Descriptor instead.
+func (*LeaveWorkspaceRequest) Descriptor() ([]byte, []int) {
+ return file_v1_workspace_service_proto_rawDescGZIP(), []int{6}
+}
+
+func (x *LeaveWorkspaceRequest) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
var File_v1_workspace_service_proto protoreflect.FileDescriptor
const file_v1_workspace_service_proto_rawDesc = "" +
"\n" +
- "\x1av1/workspace_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a google/protobuf/field_mask.proto\x1a\x13v1/annotation.proto\x1a\x13v1/iam_policy.proto\"\x17\n" +
+ "\x1av1/workspace_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a google/protobuf/field_mask.proto\x1a\x13v1/annotation.proto\x1a\x15v1/auth_service.proto\x1a\x13v1/iam_policy.proto\"\x17\n" +
"\x15ListWorkspacesRequest\"P\n" +
"\x16ListWorkspacesResponse\x126\n" +
"\n" +
@@ -278,16 +368,22 @@ const file_v1_workspace_service_proto_rawDesc = "" +
"\tWorkspace\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" +
"\x05title\x18\x02 \x01(\tR\x05title\x12\x12\n" +
- "\x04logo\x18\x03 \x01(\tR\x04logo\"\x90\x01\n" +
+ "\x04logo\x18\x03 \x01(\tR\x04logo\"1\n" +
+ "\x16DeleteWorkspaceRequest\x12\x17\n" +
+ "\x04name\x18\x01 \x01(\tB\x03\xe0A\x02R\x04name\"\x90\x01\n" +
"\x16UpdateWorkspaceRequest\x129\n" +
"\tworkspace\x18\x01 \x01(\v2\x16.bytebase.v1.WorkspaceB\x03\xe0A\x02R\tworkspace\x12;\n" +
"\vupdate_mask\x18\x02 \x01(\v2\x1a.google.protobuf.FieldMaskR\n" +
- "updateMask2\xdc\x05\n" +
+ "updateMask\"0\n" +
+ "\x15LeaveWorkspaceRequest\x12\x17\n" +
+ "\x04name\x18\x01 \x01(\tB\x03\xe0A\x02R\x04name2\xf7\a\n" +
"\x10WorkspaceService\x12m\n" +
"\fGetWorkspace\x12 .bytebase.v1.GetWorkspaceRequest\x1a\x16.bytebase.v1.Workspace\"#\x80\xea0\x01\x82\xd3\xe4\x93\x02\x19\x12\x17/v1/{name=workspaces/*}\x12u\n" +
"\x0eListWorkspaces\x12\".bytebase.v1.ListWorkspacesRequest\x1a#.bytebase.v1.ListWorkspacesResponse\"\x1a\x90\xea0\x02\x82\xd3\xe4\x93\x02\x10\x12\x0e/v1/workspaces\x12\x9c\x01\n" +
"\x0fUpdateWorkspace\x12#.bytebase.v1.UpdateWorkspaceRequest\x1a\x16.bytebase.v1.Workspace\"L\x8a\xea0\x14bb.workspaces.update\x90\xea0\x01\x98\xea0\x01\x82\xd3\xe4\x93\x02&:\x01*2!/v1/{workspace.name=workspaces/*}\x12\x9c\x01\n" +
- "\fGetIamPolicy\x12 .bytebase.v1.GetIamPolicyRequest\x1a\x16.bytebase.v1.IamPolicy\"R\x8a\xea0\x1abb.workspaces.getIamPolicy\x90\xea0\x01\x82\xd3\xe4\x93\x02*\x12(/v1/{resource=workspaces/*}:getIamPolicy\x12\xa3\x01\n" +
+ "\fGetIamPolicy\x12 .bytebase.v1.GetIamPolicyRequest\x1a\x16.bytebase.v1.IamPolicy\"R\x8a\xea0\x1abb.workspaces.getIamPolicy\x90\xea0\x01\x82\xd3\xe4\x93\x02*\x12(/v1/{resource=workspaces/*}:getIamPolicy\x12\x93\x01\n" +
+ "\x0fDeleteWorkspace\x12#.bytebase.v1.DeleteWorkspaceRequest\x1a\x1a.bytebase.v1.LoginResponse\"?\x8a\xea0\x14bb.workspaces.delete\x90\xea0\x01\x98\xea0\x01\x82\xd3\xe4\x93\x02\x19*\x17/v1/{name=workspaces/*}\x12\x82\x01\n" +
+ "\x0eLeaveWorkspace\x12\".bytebase.v1.LeaveWorkspaceRequest\x1a\x1a.bytebase.v1.LoginResponse\"0\x90\xea0\x02\x98\xea0\x01\x82\xd3\xe4\x93\x02\":\x01*\"\x1d/v1/{name=workspaces/*}:leave\x12\xa3\x01\n" +
"\fSetIamPolicy\x12 .bytebase.v1.SetIamPolicyRequest\x1a\x16.bytebase.v1.IamPolicy\"Y\x8a\xea0\x1abb.workspaces.setIamPolicy\x90\xea0\x01\x98\xea0\x01\x82\xd3\xe4\x93\x02-:\x01*\"(/v1/{resource=workspaces/*}:setIamPolicyB\xab\x01\n" +
"\x0fcom.bytebase.v1B\x15WorkspaceServiceProtoP\x01Z4github.com/bytebase/bytebase/backend/generated-go/v1\xa2\x02\x03BXX\xaa\x02\vBytebase.V1\xca\x02\vBytebase\\V1\xe2\x02\x17Bytebase\\V1\\GPBMetadata\xea\x02\fBytebase::V1b\x06proto3"
@@ -303,37 +399,44 @@ func file_v1_workspace_service_proto_rawDescGZIP() []byte {
return file_v1_workspace_service_proto_rawDescData
}
-var file_v1_workspace_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
+var file_v1_workspace_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_v1_workspace_service_proto_goTypes = []any{
(*ListWorkspacesRequest)(nil), // 0: bytebase.v1.ListWorkspacesRequest
(*ListWorkspacesResponse)(nil), // 1: bytebase.v1.ListWorkspacesResponse
(*GetWorkspaceRequest)(nil), // 2: bytebase.v1.GetWorkspaceRequest
(*Workspace)(nil), // 3: bytebase.v1.Workspace
- (*UpdateWorkspaceRequest)(nil), // 4: bytebase.v1.UpdateWorkspaceRequest
- (*fieldmaskpb.FieldMask)(nil), // 5: google.protobuf.FieldMask
- (*GetIamPolicyRequest)(nil), // 6: bytebase.v1.GetIamPolicyRequest
- (*SetIamPolicyRequest)(nil), // 7: bytebase.v1.SetIamPolicyRequest
- (*IamPolicy)(nil), // 8: bytebase.v1.IamPolicy
+ (*DeleteWorkspaceRequest)(nil), // 4: bytebase.v1.DeleteWorkspaceRequest
+ (*UpdateWorkspaceRequest)(nil), // 5: bytebase.v1.UpdateWorkspaceRequest
+ (*LeaveWorkspaceRequest)(nil), // 6: bytebase.v1.LeaveWorkspaceRequest
+ (*fieldmaskpb.FieldMask)(nil), // 7: google.protobuf.FieldMask
+ (*GetIamPolicyRequest)(nil), // 8: bytebase.v1.GetIamPolicyRequest
+ (*SetIamPolicyRequest)(nil), // 9: bytebase.v1.SetIamPolicyRequest
+ (*IamPolicy)(nil), // 10: bytebase.v1.IamPolicy
+ (*LoginResponse)(nil), // 11: bytebase.v1.LoginResponse
}
var file_v1_workspace_service_proto_depIdxs = []int32{
- 3, // 0: bytebase.v1.ListWorkspacesResponse.workspaces:type_name -> bytebase.v1.Workspace
- 3, // 1: bytebase.v1.UpdateWorkspaceRequest.workspace:type_name -> bytebase.v1.Workspace
- 5, // 2: bytebase.v1.UpdateWorkspaceRequest.update_mask:type_name -> google.protobuf.FieldMask
- 2, // 3: bytebase.v1.WorkspaceService.GetWorkspace:input_type -> bytebase.v1.GetWorkspaceRequest
- 0, // 4: bytebase.v1.WorkspaceService.ListWorkspaces:input_type -> bytebase.v1.ListWorkspacesRequest
- 4, // 5: bytebase.v1.WorkspaceService.UpdateWorkspace:input_type -> bytebase.v1.UpdateWorkspaceRequest
- 6, // 6: bytebase.v1.WorkspaceService.GetIamPolicy:input_type -> bytebase.v1.GetIamPolicyRequest
- 7, // 7: bytebase.v1.WorkspaceService.SetIamPolicy:input_type -> bytebase.v1.SetIamPolicyRequest
- 3, // 8: bytebase.v1.WorkspaceService.GetWorkspace:output_type -> bytebase.v1.Workspace
- 1, // 9: bytebase.v1.WorkspaceService.ListWorkspaces:output_type -> bytebase.v1.ListWorkspacesResponse
- 3, // 10: bytebase.v1.WorkspaceService.UpdateWorkspace:output_type -> bytebase.v1.Workspace
- 8, // 11: bytebase.v1.WorkspaceService.GetIamPolicy:output_type -> bytebase.v1.IamPolicy
- 8, // 12: bytebase.v1.WorkspaceService.SetIamPolicy:output_type -> bytebase.v1.IamPolicy
- 8, // [8:13] is the sub-list for method output_type
- 3, // [3:8] is the sub-list for method input_type
- 3, // [3:3] is the sub-list for extension type_name
- 3, // [3:3] is the sub-list for extension extendee
- 0, // [0:3] is the sub-list for field type_name
+ 3, // 0: bytebase.v1.ListWorkspacesResponse.workspaces:type_name -> bytebase.v1.Workspace
+ 3, // 1: bytebase.v1.UpdateWorkspaceRequest.workspace:type_name -> bytebase.v1.Workspace
+ 7, // 2: bytebase.v1.UpdateWorkspaceRequest.update_mask:type_name -> google.protobuf.FieldMask
+ 2, // 3: bytebase.v1.WorkspaceService.GetWorkspace:input_type -> bytebase.v1.GetWorkspaceRequest
+ 0, // 4: bytebase.v1.WorkspaceService.ListWorkspaces:input_type -> bytebase.v1.ListWorkspacesRequest
+ 5, // 5: bytebase.v1.WorkspaceService.UpdateWorkspace:input_type -> bytebase.v1.UpdateWorkspaceRequest
+ 8, // 6: bytebase.v1.WorkspaceService.GetIamPolicy:input_type -> bytebase.v1.GetIamPolicyRequest
+ 4, // 7: bytebase.v1.WorkspaceService.DeleteWorkspace:input_type -> bytebase.v1.DeleteWorkspaceRequest
+ 6, // 8: bytebase.v1.WorkspaceService.LeaveWorkspace:input_type -> bytebase.v1.LeaveWorkspaceRequest
+ 9, // 9: bytebase.v1.WorkspaceService.SetIamPolicy:input_type -> bytebase.v1.SetIamPolicyRequest
+ 3, // 10: bytebase.v1.WorkspaceService.GetWorkspace:output_type -> bytebase.v1.Workspace
+ 1, // 11: bytebase.v1.WorkspaceService.ListWorkspaces:output_type -> bytebase.v1.ListWorkspacesResponse
+ 3, // 12: bytebase.v1.WorkspaceService.UpdateWorkspace:output_type -> bytebase.v1.Workspace
+ 10, // 13: bytebase.v1.WorkspaceService.GetIamPolicy:output_type -> bytebase.v1.IamPolicy
+ 11, // 14: bytebase.v1.WorkspaceService.DeleteWorkspace:output_type -> bytebase.v1.LoginResponse
+ 11, // 15: bytebase.v1.WorkspaceService.LeaveWorkspace:output_type -> bytebase.v1.LoginResponse
+ 10, // 16: bytebase.v1.WorkspaceService.SetIamPolicy:output_type -> bytebase.v1.IamPolicy
+ 10, // [10:17] is the sub-list for method output_type
+ 3, // [3:10] is the sub-list for method input_type
+ 3, // [3:3] is the sub-list for extension type_name
+ 3, // [3:3] is the sub-list for extension extendee
+ 0, // [0:3] is the sub-list for field type_name
}
func init() { file_v1_workspace_service_proto_init() }
@@ -342,6 +445,7 @@ func file_v1_workspace_service_proto_init() {
return
}
file_v1_annotation_proto_init()
+ file_v1_auth_service_proto_init()
file_v1_iam_policy_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
@@ -349,7 +453,7 @@ func file_v1_workspace_service_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_workspace_service_proto_rawDesc), len(file_v1_workspace_service_proto_rawDesc)),
NumEnums: 0,
- NumMessages: 5,
+ NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/backend/generated-go/v1/workspace_service.pb.gw.go b/backend/generated-go/v1/workspace_service.pb.gw.go
index f326aed22d..6855d16158 100644
--- a/backend/generated-go/v1/workspace_service.pb.gw.go
+++ b/backend/generated-go/v1/workspace_service.pb.gw.go
@@ -179,6 +179,90 @@ func local_request_WorkspaceService_GetIamPolicy_0(ctx context.Context, marshale
return msg, metadata, err
}
+func request_WorkspaceService_DeleteWorkspace_0(ctx context.Context, marshaler runtime.Marshaler, client WorkspaceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq DeleteWorkspaceRequest
+ metadata runtime.ServerMetadata
+ err error
+ )
+ if req.Body != nil {
+ _, _ = io.Copy(io.Discard, req.Body)
+ }
+ val, ok := pathParams["name"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
+ }
+ protoReq.Name, err = runtime.String(val)
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
+ }
+ msg, err := client.DeleteWorkspace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_WorkspaceService_DeleteWorkspace_0(ctx context.Context, marshaler runtime.Marshaler, server WorkspaceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq DeleteWorkspaceRequest
+ metadata runtime.ServerMetadata
+ err error
+ )
+ val, ok := pathParams["name"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
+ }
+ protoReq.Name, err = runtime.String(val)
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
+ }
+ msg, err := server.DeleteWorkspace(ctx, &protoReq)
+ return msg, metadata, err
+}
+
+func request_WorkspaceService_LeaveWorkspace_0(ctx context.Context, marshaler runtime.Marshaler, client WorkspaceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq LeaveWorkspaceRequest
+ metadata runtime.ServerMetadata
+ err error
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ if req.Body != nil {
+ _, _ = io.Copy(io.Discard, req.Body)
+ }
+ val, ok := pathParams["name"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
+ }
+ protoReq.Name, err = runtime.String(val)
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
+ }
+ msg, err := client.LeaveWorkspace(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_WorkspaceService_LeaveWorkspace_0(ctx context.Context, marshaler runtime.Marshaler, server WorkspaceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq LeaveWorkspaceRequest
+ metadata runtime.ServerMetadata
+ err error
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ val, ok := pathParams["name"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
+ }
+ protoReq.Name, err = runtime.String(val)
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
+ }
+ msg, err := server.LeaveWorkspace(ctx, &protoReq)
+ return msg, metadata, err
+}
+
func request_WorkspaceService_SetIamPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client WorkspaceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq SetIamPolicyRequest
@@ -310,6 +394,46 @@ func RegisterWorkspaceServiceHandlerServer(ctx context.Context, mux *runtime.Ser
}
forward_WorkspaceService_GetIamPolicy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodDelete, pattern_WorkspaceService_DeleteWorkspace_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)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.WorkspaceService/DeleteWorkspace", runtime.WithHTTPPathPattern("/v1/{name=workspaces/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_WorkspaceService_DeleteWorkspace_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_WorkspaceService_DeleteWorkspace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodPost, pattern_WorkspaceService_LeaveWorkspace_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)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.WorkspaceService/LeaveWorkspace", runtime.WithHTTPPathPattern("/v1/{name=workspaces/*}:leave"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_WorkspaceService_LeaveWorkspace_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_WorkspaceService_LeaveWorkspace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
mux.Handle(http.MethodPost, pattern_WorkspaceService_SetIamPolicy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -438,6 +562,40 @@ func RegisterWorkspaceServiceHandlerClient(ctx context.Context, mux *runtime.Ser
}
forward_WorkspaceService_GetIamPolicy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodDelete, pattern_WorkspaceService_DeleteWorkspace_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)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.WorkspaceService/DeleteWorkspace", runtime.WithHTTPPathPattern("/v1/{name=workspaces/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_WorkspaceService_DeleteWorkspace_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_WorkspaceService_DeleteWorkspace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
+ mux.Handle(http.MethodPost, pattern_WorkspaceService_LeaveWorkspace_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)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.WorkspaceService/LeaveWorkspace", runtime.WithHTTPPathPattern("/v1/{name=workspaces/*}:leave"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_WorkspaceService_LeaveWorkspace_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_WorkspaceService_LeaveWorkspace_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
mux.Handle(http.MethodPost, pattern_WorkspaceService_SetIamPolicy_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -463,6 +621,8 @@ var (
pattern_WorkspaceService_ListWorkspaces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "workspaces"}, ""))
pattern_WorkspaceService_UpdateWorkspace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "workspaces", "workspace.name"}, ""))
pattern_WorkspaceService_GetIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "workspaces", "resource"}, "getIamPolicy"))
+ pattern_WorkspaceService_DeleteWorkspace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "workspaces", "name"}, ""))
+ pattern_WorkspaceService_LeaveWorkspace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "workspaces", "name"}, "leave"))
pattern_WorkspaceService_SetIamPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "workspaces", "resource"}, "setIamPolicy"))
)
@@ -471,5 +631,7 @@ var (
forward_WorkspaceService_ListWorkspaces_0 = runtime.ForwardResponseMessage
forward_WorkspaceService_UpdateWorkspace_0 = runtime.ForwardResponseMessage
forward_WorkspaceService_GetIamPolicy_0 = runtime.ForwardResponseMessage
+ forward_WorkspaceService_DeleteWorkspace_0 = runtime.ForwardResponseMessage
+ forward_WorkspaceService_LeaveWorkspace_0 = runtime.ForwardResponseMessage
forward_WorkspaceService_SetIamPolicy_0 = runtime.ForwardResponseMessage
)
diff --git a/backend/generated-go/v1/workspace_service_equal.pb.go b/backend/generated-go/v1/workspace_service_equal.pb.go
index a9a57db10f..247ad2ec5c 100644
--- a/backend/generated-go/v1/workspace_service_equal.pb.go
+++ b/backend/generated-go/v1/workspace_service_equal.pb.go
@@ -68,6 +68,19 @@ func (x *Workspace) Equal(y *Workspace) bool {
return true
}
+func (x *DeleteWorkspaceRequest) Equal(y *DeleteWorkspaceRequest) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Name != y.Name {
+ return false
+ }
+ return true
+}
+
func (x *UpdateWorkspaceRequest) Equal(y *UpdateWorkspaceRequest) bool {
if x == y {
return true
@@ -87,3 +100,16 @@ func (x *UpdateWorkspaceRequest) Equal(y *UpdateWorkspaceRequest) bool {
}
return true
}
+
+func (x *LeaveWorkspaceRequest) Equal(y *LeaveWorkspaceRequest) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Name != y.Name {
+ return false
+ }
+ return true
+}
diff --git a/backend/generated-go/v1/workspace_service_grpc.pb.go b/backend/generated-go/v1/workspace_service_grpc.pb.go
index d174b2b179..b7f1e23146 100644
--- a/backend/generated-go/v1/workspace_service_grpc.pb.go
+++ b/backend/generated-go/v1/workspace_service_grpc.pb.go
@@ -23,6 +23,8 @@ const (
WorkspaceService_ListWorkspaces_FullMethodName = "/bytebase.v1.WorkspaceService/ListWorkspaces"
WorkspaceService_UpdateWorkspace_FullMethodName = "/bytebase.v1.WorkspaceService/UpdateWorkspace"
WorkspaceService_GetIamPolicy_FullMethodName = "/bytebase.v1.WorkspaceService/GetIamPolicy"
+ WorkspaceService_DeleteWorkspace_FullMethodName = "/bytebase.v1.WorkspaceService/DeleteWorkspace"
+ WorkspaceService_LeaveWorkspace_FullMethodName = "/bytebase.v1.WorkspaceService/LeaveWorkspace"
WorkspaceService_SetIamPolicy_FullMethodName = "/bytebase.v1.WorkspaceService/SetIamPolicy"
)
@@ -45,6 +47,14 @@ type WorkspaceServiceClient interface {
// Retrieves IAM policy for the workspace.
// Permissions required: bb.workspaces.getIamPolicy
GetIamPolicy(ctx context.Context, in *GetIamPolicyRequest, opts ...grpc.CallOption) (*IamPolicy, error)
+ // Deletes a workspace. SaaS only. Cancels any active subscription and
+ // soft-deletes the workspace so all associated data becomes inaccessible.
+ // Requires workspace admin permission.
+ DeleteWorkspace(ctx context.Context, in *DeleteWorkspaceRequest, opts ...grpc.CallOption) (*LoginResponse, error)
+ // Removes the calling user from a workspace and switches to the next
+ // available workspace. Available to any workspace member. Fails if the
+ // caller is the last workspace admin.
+ LeaveWorkspace(ctx context.Context, in *LeaveWorkspaceRequest, opts ...grpc.CallOption) (*LoginResponse, error)
// Sets IAM policy for the workspace.
// Permissions required: bb.workspaces.setIamPolicy
SetIamPolicy(ctx context.Context, in *SetIamPolicyRequest, opts ...grpc.CallOption) (*IamPolicy, error)
@@ -98,6 +108,26 @@ func (c *workspaceServiceClient) GetIamPolicy(ctx context.Context, in *GetIamPol
return out, nil
}
+func (c *workspaceServiceClient) DeleteWorkspace(ctx context.Context, in *DeleteWorkspaceRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(LoginResponse)
+ err := c.cc.Invoke(ctx, WorkspaceService_DeleteWorkspace_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *workspaceServiceClient) LeaveWorkspace(ctx context.Context, in *LeaveWorkspaceRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(LoginResponse)
+ err := c.cc.Invoke(ctx, WorkspaceService_LeaveWorkspace_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
func (c *workspaceServiceClient) SetIamPolicy(ctx context.Context, in *SetIamPolicyRequest, opts ...grpc.CallOption) (*IamPolicy, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(IamPolicy)
@@ -127,6 +157,14 @@ type WorkspaceServiceServer interface {
// Retrieves IAM policy for the workspace.
// Permissions required: bb.workspaces.getIamPolicy
GetIamPolicy(context.Context, *GetIamPolicyRequest) (*IamPolicy, error)
+ // Deletes a workspace. SaaS only. Cancels any active subscription and
+ // soft-deletes the workspace so all associated data becomes inaccessible.
+ // Requires workspace admin permission.
+ DeleteWorkspace(context.Context, *DeleteWorkspaceRequest) (*LoginResponse, error)
+ // Removes the calling user from a workspace and switches to the next
+ // available workspace. Available to any workspace member. Fails if the
+ // caller is the last workspace admin.
+ LeaveWorkspace(context.Context, *LeaveWorkspaceRequest) (*LoginResponse, error)
// Sets IAM policy for the workspace.
// Permissions required: bb.workspaces.setIamPolicy
SetIamPolicy(context.Context, *SetIamPolicyRequest) (*IamPolicy, error)
@@ -152,6 +190,12 @@ func (UnimplementedWorkspaceServiceServer) UpdateWorkspace(context.Context, *Upd
func (UnimplementedWorkspaceServiceServer) GetIamPolicy(context.Context, *GetIamPolicyRequest) (*IamPolicy, error) {
return nil, status.Error(codes.Unimplemented, "method GetIamPolicy not implemented")
}
+func (UnimplementedWorkspaceServiceServer) DeleteWorkspace(context.Context, *DeleteWorkspaceRequest) (*LoginResponse, error) {
+ return nil, status.Error(codes.Unimplemented, "method DeleteWorkspace not implemented")
+}
+func (UnimplementedWorkspaceServiceServer) LeaveWorkspace(context.Context, *LeaveWorkspaceRequest) (*LoginResponse, error) {
+ return nil, status.Error(codes.Unimplemented, "method LeaveWorkspace not implemented")
+}
func (UnimplementedWorkspaceServiceServer) SetIamPolicy(context.Context, *SetIamPolicyRequest) (*IamPolicy, error) {
return nil, status.Error(codes.Unimplemented, "method SetIamPolicy not implemented")
}
@@ -248,6 +292,42 @@ func _WorkspaceService_GetIamPolicy_Handler(srv interface{}, ctx context.Context
return interceptor(ctx, in, info, handler)
}
+func _WorkspaceService_DeleteWorkspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(DeleteWorkspaceRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(WorkspaceServiceServer).DeleteWorkspace(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: WorkspaceService_DeleteWorkspace_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(WorkspaceServiceServer).DeleteWorkspace(ctx, req.(*DeleteWorkspaceRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _WorkspaceService_LeaveWorkspace_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(LeaveWorkspaceRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(WorkspaceServiceServer).LeaveWorkspace(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: WorkspaceService_LeaveWorkspace_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(WorkspaceServiceServer).LeaveWorkspace(ctx, req.(*LeaveWorkspaceRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
func _WorkspaceService_SetIamPolicy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SetIamPolicyRequest)
if err := dec(in); err != nil {
@@ -289,6 +369,14 @@ var WorkspaceService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetIamPolicy",
Handler: _WorkspaceService_GetIamPolicy_Handler,
},
+ {
+ MethodName: "DeleteWorkspace",
+ Handler: _WorkspaceService_DeleteWorkspace_Handler,
+ },
+ {
+ MethodName: "LeaveWorkspace",
+ Handler: _WorkspaceService_LeaveWorkspace_Handler,
+ },
{
MethodName: "SetIamPolicy",
Handler: _WorkspaceService_SetIamPolicy_Handler,
diff --git a/backend/server/grpc_routes.go b/backend/server/grpc_routes.go
index da4d6ff8a0..dbdd474345 100644
--- a/backend/server/grpc_routes.go
+++ b/backend/server/grpc_routes.go
@@ -117,7 +117,7 @@ func configureGrpcRouters(
serviceAccountService := apiv1.NewServiceAccountService(stores, profile, iamManager)
workloadIdentityService := apiv1.NewWorkloadIdentityService(stores, profile, iamManager)
worksheetService := apiv1.NewWorksheetService(stores, iamManager)
- workspaceService := apiv1.NewWorkspaceService(stores, iamManager, profile, licenseService)
+ workspaceService := apiv1.NewWorkspaceService(stores, iamManager, profile, licenseService, authService)
onPanic := func(_ context.Context, s connect.Spec, _ http.Header, p any) error {
stack := stacktrace.TakeStacktrace(20 /* n */, 5 /* skip */)
diff --git a/backend/store/group.go b/backend/store/group.go
index 7550b71d29..173086cca6 100644
--- a/backend/store/group.go
+++ b/backend/store/group.go
@@ -325,6 +325,31 @@ func (s *Store) DeleteGroup(ctx context.Context, workspace string, id string) er
return nil
}
+// RemoveMemberFromAllGroups removes a user from all groups in a workspace via a single SQL update.
+// member format is "users/{email}".
+func (s *Store) RemoveMemberFromAllGroups(ctx context.Context, workspaceID string, member string) error {
+ query := `
+ UPDATE user_group
+ SET payload = jsonb_set(
+ payload,
+ '{members}',
+ COALESCE(
+ (SELECT jsonb_agg(m) FROM jsonb_array_elements(payload->'members') m WHERE m->>'member' != $1),
+ '[]'::jsonb
+ )
+ )
+ WHERE workspace = $2
+ AND EXISTS (SELECT 1 FROM jsonb_array_elements(payload->'members') m WHERE m->>'member' = $1)`
+ if _, err := s.GetDB().ExecContext(ctx, query, member, workspaceID); err != nil {
+ return errors.Wrapf(err, "failed to remove member %q from groups in workspace %q", member, workspaceID)
+ }
+ // Purge caches since we can't know which groups were affected.
+ s.groupCache.Purge()
+ s.groupMembersCache.Purge()
+ s.memberGroupsCache.Purge()
+ return nil
+}
+
// GetUserGroupsSnapshot returns groups for a user with snapshot reads (with cache).
// userName format is "users/{email}".
// Trades consistency for performance.
diff --git a/backend/store/predefined_roles.go b/backend/store/predefined_roles.go
index a7290cb36d..18859f5b70 100644
--- a/backend/store/predefined_roles.go
+++ b/backend/store/predefined_roles.go
@@ -158,6 +158,7 @@ var PredefinedRoles = []*RoleMessage{
permission.WorksheetsManage,
permission.WorkspacesGetIamPolicy,
permission.WorkspacesUpdate,
+ permission.WorkspacesDelete,
permission.WorkspacesSetIamPolicy,
permission.SubscriptionManage,
permission.ServiceAccountsCreate,
diff --git a/backend/store/workspace.go b/backend/store/workspace.go
index 364ee78037..d7ad3d905b 100644
--- a/backend/store/workspace.go
+++ b/backend/store/workspace.go
@@ -226,6 +226,27 @@ func (s *Store) UpdateWorkspace(ctx context.Context, patch *UpdateWorkspaceMessa
return nil
}
+// DeleteWorkspace soft-deletes a workspace by setting deleted = TRUE.
+func (s *Store) DeleteWorkspace(ctx context.Context, resourceID string) error {
+ q := qb.Q().Space("UPDATE workspace SET deleted = TRUE WHERE resource_id = ? AND deleted = FALSE", resourceID)
+ query, args, err := q.ToSQL()
+ if err != nil {
+ return errors.Wrapf(err, "failed to build sql")
+ }
+ result, err := s.GetDB().ExecContext(ctx, query, args...)
+ if err != nil {
+ return errors.Wrapf(err, "failed to delete workspace")
+ }
+ rows, err := result.RowsAffected()
+ if err != nil {
+ return errors.Wrapf(err, "failed to get rows affected")
+ }
+ if rows == 0 {
+ return errors.Errorf("workspace %q not found or already deleted", resourceID)
+ }
+ return nil
+}
+
// FindWorkspaceMessage is the message for finding workspaces.
type FindWorkspaceMessage struct {
// WorkspaceID filters by a specific workspace. Nil means no filter.
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index db7a5f1183..4f028bc65b 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -2158,6 +2158,22 @@
"branding": "Branding",
"config-partly-updated": "Configuration partly updated.",
"config-updated": "Configuration is updated.",
+ "danger-zone": {
+ "confirm-description": "This will permanently delete the workspace \"{{workspace}}\" and all its data. This action cannot be undone. Type the workspace name to confirm.",
+ "confirm-title": "Delete workspace?",
+ "delete-failed": "Failed to delete workspace.",
+ "delete-workspace": "Delete workspace",
+ "deleted": "Workspace deleted.",
+ "deleting": "Deleting...",
+ "description": "Once you delete a workspace, all projects, databases, issues, and settings within it will be permanently removed. This action cannot be undone.",
+ "exit-confirm-description": "You will lose access to workspace \"{{workspace}}\". You will need to be re-invited to rejoin.",
+ "exit-confirm-title": "Exit workspace?",
+ "exit-description": "Leave this workspace and remove your access. You will need to be re-invited to rejoin.",
+ "exit-failed": "Failed to exit workspace.",
+ "exit-workspace": "Exit workspace",
+ "exited": "You have exited the workspace.",
+ "exiting": "Exiting..."
+ },
"data-copy": "Enable data copying",
"data-export": "Enable data export",
"default-landing-page": {
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index 25ee32b5e4..c5579dbd98 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -2147,6 +2147,22 @@
"branding": "Marca",
"config-partly-updated": "Configuración parcialmente actualizada.",
"config-updated": "La configuración se ha actualizado.",
+ "danger-zone": {
+ "confirm-description": "Esto eliminará permanentemente el espacio de trabajo \"{{workspace}}\" y todos sus datos. Esta acción no se puede deshacer. Escriba el nombre del espacio de trabajo para confirmar.",
+ "confirm-title": "¿Eliminar espacio de trabajo?",
+ "delete-failed": "Error al eliminar el espacio de trabajo.",
+ "delete-workspace": "Eliminar espacio de trabajo",
+ "deleted": "Espacio de trabajo eliminado.",
+ "deleting": "Eliminando...",
+ "description": "Una vez que elimine un espacio de trabajo, todos los proyectos, bases de datos, incidencias y configuraciones dentro de él se eliminarán permanentemente. Esta acción no se puede deshacer.",
+ "exit-confirm-description": "Perderá el acceso al espacio de trabajo \"{{workspace}}\". Necesitará ser reinvitado para volver a unirse.",
+ "exit-confirm-title": "¿Salir del espacio de trabajo?",
+ "exit-description": "Abandonar este espacio de trabajo y eliminar su acceso. Necesitará ser reinvitado para volver a unirse.",
+ "exit-failed": "Error al salir del espacio de trabajo.",
+ "exit-workspace": "Salir del espacio de trabajo",
+ "exited": "Ha salido del espacio de trabajo.",
+ "exiting": "Saliendo..."
+ },
"data-copy": "Habilitar la copia de datos",
"data-export": "Habilitar la exportación de datos",
"default-landing-page": {
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index b3f19f186f..490ee3eef4 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -2147,6 +2147,22 @@
"branding": "ブランド",
"config-partly-updated": "設定が部分的に更新されました。",
"config-updated": "設定が更新されました。",
+ "danger-zone": {
+ "confirm-description": "ワークスペース「{{workspace}}」とそのすべてのデータが完全に削除されます。この操作は元に戻せません。確認のためワークスペース名を入力してください。",
+ "confirm-title": "ワークスペースを削除しますか?",
+ "delete-failed": "ワークスペースの削除に失敗しました。",
+ "delete-workspace": "ワークスペースを削除",
+ "deleted": "ワークスペースが削除されました。",
+ "deleting": "削除中...",
+ "description": "ワークスペースを削除すると、すべてのプロジェクト、データベース、課題、設定が完全に削除され、元に戻すことはできません。",
+ "exit-confirm-description": "ワークスペース「{{workspace}}」へのアクセスを失います。再参加するには再度招待を受ける必要があります。",
+ "exit-confirm-title": "ワークスペースを退出しますか?",
+ "exit-description": "このワークスペースを離れ、アクセス権を削除します。再参加するには再度招待を受ける必要があります。",
+ "exit-failed": "ワークスペースの退出に失敗しました。",
+ "exit-workspace": "ワークスペースを退出",
+ "exited": "ワークスペースを退出しました。",
+ "exiting": "退出中..."
+ },
"data-copy": "データのコピーを有効にする",
"data-export": "データのエクスポートを有効にする",
"default-landing-page": {
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index 61043d743a..b460e7ef50 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -2147,6 +2147,22 @@
"branding": "Thương hiệu",
"config-partly-updated": "Cấu hình đã được cập nhật một phần.",
"config-updated": "Cấu hình được cập nhật.",
+ "danger-zone": {
+ "confirm-description": "Hành động này sẽ xóa vĩnh viễn không gian làm việc \"{{workspace}}\" và tất cả dữ liệu của nó. Không thể hoàn tác. Nhập tên không gian làm việc để xác nhận.",
+ "confirm-title": "Xóa không gian làm việc?",
+ "delete-failed": "Không thể xóa không gian làm việc.",
+ "delete-workspace": "Xóa không gian làm việc",
+ "deleted": "Đã xóa không gian làm việc.",
+ "deleting": "Đang xóa...",
+ "description": "Khi bạn xóa không gian làm việc, tất cả dự án, cơ sở dữ liệu, vấn đề và cài đặt trong đó sẽ bị xóa vĩnh viễn. Không thể hoàn tác hành động này.",
+ "exit-confirm-description": "Bạn sẽ mất quyền truy cập vào không gian làm việc \"{{workspace}}\". Bạn cần được mời lại để tham gia.",
+ "exit-confirm-title": "Rời khỏi không gian làm việc?",
+ "exit-description": "Rời khỏi không gian làm việc này và xóa quyền truy cập của bạn. Bạn cần được mời lại để tham gia.",
+ "exit-failed": "Không thể rời khỏi không gian làm việc.",
+ "exit-workspace": "Rời khỏi không gian làm việc",
+ "exited": "Bạn đã rời khỏi không gian làm việc.",
+ "exiting": "Đang rời..."
+ },
"data-copy": "Bật sao chép dữ liệu",
"data-export": "Bật xuất dữ liệu",
"default-landing-page": {
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index 9cfba16f78..77792e20ad 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -2147,6 +2147,22 @@
"branding": "品牌",
"config-partly-updated": "配置部分更新。",
"config-updated": "配置已更新。",
+ "danger-zone": {
+ "confirm-description": "此操作将永久删除工作空间「{{workspace}}」及其所有数据,且无法撤销。请输入工作空间名称以确认。",
+ "confirm-title": "删除工作空间?",
+ "delete-failed": "删除工作空间失败。",
+ "delete-workspace": "删除工作空间",
+ "deleted": "工作空间已删除。",
+ "deleting": "删除中...",
+ "description": "删除工作空间后,其中的所有项目、数据库、工单和设置将被永久移除,且无法恢复。",
+ "exit-confirm-description": "您将失去对工作空间「{{workspace}}」的访问权限。需要重新被邀请才能重新加入。",
+ "exit-confirm-title": "退出工作空间?",
+ "exit-description": "离开此工作空间并移除您的访问权限。需要重新被邀请才能重新加入。",
+ "exit-failed": "退出工作空间失败。",
+ "exit-workspace": "退出工作空间",
+ "exited": "您已退出工作空间。",
+ "exiting": "退出中..."
+ },
"data-copy": "启用复制数据",
"data-export": "启用数据导出",
"default-landing-page": {
diff --git a/frontend/src/react/pages/settings/general/DangerZoneSection.tsx b/frontend/src/react/pages/settings/general/DangerZoneSection.tsx
new file mode 100644
index 0000000000..34ba2cac4e
--- /dev/null
+++ b/frontend/src/react/pages/settings/general/DangerZoneSection.tsx
@@ -0,0 +1,238 @@
+import { useCallback, useMemo, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { workspaceServiceClientConnect } from "@/connect";
+import {
+ AlertDialog,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogTitle,
+} from "@/react/components/ui/alert-dialog";
+import { Button } from "@/react/components/ui/button";
+import { Input } from "@/react/components/ui/input";
+import { useCurrentUser, useWorkspace } from "@/react/hooks/useAppState";
+import { useVueState } from "@/react/hooks/useVueState";
+import { pushNotification, useWorkspaceV1Store } from "@/store";
+import { PresetRoleType } from "@/types/iam/role";
+import { userBindingPrefix } from "@/types/v1/user";
+import { hasWorkspacePermissionV2 } from "@/utils";
+
+export function DangerZoneSection() {
+ const { t } = useTranslation();
+ const workspace = useWorkspace();
+ const currentUser = useCurrentUser()!;
+ const workspaceStore = useWorkspaceV1Store();
+ const workspacePolicy = useVueState(() => workspaceStore.workspaceIamPolicy);
+
+ const canDelete = hasWorkspacePermissionV2("bb.workspaces.delete");
+
+ // Check if there are other admins in the workspace besides the current user.
+ // Group bindings (group:...) are treated as "other admin" since they may
+ // contain other users — the backend does the definitive check.
+ const hasOtherAdmin = useMemo(() => {
+ const currentBinding = `${userBindingPrefix}${currentUser.email}`;
+ for (const binding of workspacePolicy.bindings) {
+ if (binding.role !== PresetRoleType.WORKSPACE_ADMIN) continue;
+ for (const member of binding.members) {
+ if (member === currentBinding) continue;
+ // A group binding counts as "other admin" — it may contain
+ // other users who are admins through the group.
+ if (member.startsWith("group:") || member.startsWith("groups/")) {
+ return true;
+ }
+ // A different direct user binding.
+ return true;
+ }
+ }
+ return false;
+ }, [workspacePolicy, currentUser.email]);
+
+ // --- Delete workspace ---
+ const [deleteOpen, setDeleteOpen] = useState(false);
+ const [confirmText, setConfirmText] = useState("");
+ const [deleting, setDeleting] = useState(false);
+ const workspaceTitle = workspace?.title ?? "";
+ const canConfirmDelete = confirmText === workspaceTitle && !deleting;
+
+ const handleDelete = useCallback(async () => {
+ if (!workspace?.name) return;
+ setDeleting(true);
+ try {
+ await workspaceServiceClientConnect.deleteWorkspace({
+ name: workspace.name,
+ });
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("settings.general.workspace.danger-zone.deleted"),
+ });
+ // The backend switches to the next workspace (new auth cookies set)
+ // or returns empty if no workspace remains (login will provision one).
+ window.location.href = "/";
+ } catch {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("settings.general.workspace.danger-zone.delete-failed"),
+ });
+ setDeleting(false);
+ }
+ }, [workspace?.name, t]);
+
+ // --- Exit workspace ---
+ const [exitOpen, setExitOpen] = useState(false);
+ const [exiting, setExiting] = useState(false);
+
+ const handleExit = useCallback(async () => {
+ if (!workspace?.name) return;
+ setExiting(true);
+ try {
+ // The backend removes the user from the workspace IAM, switches to
+ // the next available workspace, and sets new auth cookies.
+ await workspaceServiceClientConnect.leaveWorkspace({
+ name: workspace.name,
+ });
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("settings.general.workspace.danger-zone.exited"),
+ });
+ window.location.href = "/";
+ } catch {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("settings.general.workspace.danger-zone.exit-failed"),
+ });
+ setExiting(false);
+ }
+ }, [workspace?.name, t]);
+
+ return (
+ <div className="py-6 lg:flex">
+ <div className="text-left lg:w-1/4">
+ <h1 className="text-2xl font-bold">{t("common.danger-zone")}</h1>
+ </div>
+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <div className="border border-error-alpha bg-error-alpha rounded-sm divide-y divide-error-alpha">
+ {/* Exit workspace */}
+ {hasOtherAdmin && (
+ <div className="p-6 flex items-start justify-between gap-x-6">
+ <div className="flex-1">
+ <h4 className="font-medium text-error">
+ {t("settings.general.workspace.danger-zone.exit-workspace")}
+ </h4>
+ <p className="text-sm text-control-light mt-1">
+ {t("settings.general.workspace.danger-zone.exit-description")}
+ </p>
+ </div>
+ <Button
+ variant="destructive"
+ disabled={exiting}
+ onClick={() => setExitOpen(true)}
+ >
+ {t("settings.general.workspace.danger-zone.exit-workspace")}
+ </Button>
+ </div>
+ )}
+
+ {/* Delete workspace */}
+ {canDelete && (
+ <div className="p-6 flex items-start justify-between gap-x-6">
+ <div className="flex-1">
+ <h4 className="font-medium text-error">
+ {t("settings.general.workspace.danger-zone.delete-workspace")}
+ </h4>
+ <p className="text-sm text-control-light mt-1">
+ {t("settings.general.workspace.danger-zone.description")}
+ </p>
+ </div>
+ <Button
+ variant="destructive"
+ disabled={deleting}
+ onClick={() => setDeleteOpen(true)}
+ >
+ {t("settings.general.workspace.danger-zone.delete-workspace")}
+ </Button>
+ </div>
+ )}
+ </div>
+ </div>
+
+ {/* Exit workspace dialog */}
+ <AlertDialog open={exitOpen}>
+ <AlertDialogContent className="max-w-md">
+ <AlertDialogTitle>
+ {t("settings.general.workspace.danger-zone.exit-confirm-title")}
+ </AlertDialogTitle>
+ <AlertDialogDescription>
+ {t(
+ "settings.general.workspace.danger-zone.exit-confirm-description",
+ { workspace: workspaceTitle }
+ )}
+ </AlertDialogDescription>
+ <AlertDialogFooter>
+ <Button
+ variant="outline"
+ onClick={() => setExitOpen(false)}
+ disabled={exiting}
+ >
+ {t("common.cancel")}
+ </Button>
+ <Button
+ variant="destructive"
+ onClick={() => void handleExit()}
+ disabled={exiting}
+ >
+ {exiting
+ ? t("settings.general.workspace.danger-zone.exiting")
+ : t("settings.general.workspace.danger-zone.exit-workspace")}
+ </Button>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+
+ {/* Delete workspace dialog */}
+ <AlertDialog open={deleteOpen}>
+ <AlertDialogContent className="max-w-md">
+ <AlertDialogTitle>
+ {t("settings.general.workspace.danger-zone.confirm-title")}
+ </AlertDialogTitle>
+ <AlertDialogDescription className="flex flex-col gap-y-3">
+ <span>
+ {t("settings.general.workspace.danger-zone.confirm-description", {
+ workspace: workspaceTitle,
+ })}
+ </span>
+ <Input
+ value={confirmText}
+ onChange={(e) => setConfirmText(e.target.value)}
+ placeholder={workspaceTitle}
+ />
+ </AlertDialogDescription>
+ <AlertDialogFooter>
+ <Button
+ variant="outline"
+ onClick={() => {
+ setDeleteOpen(false);
+ setConfirmText("");
+ }}
+ disabled={deleting}
+ >
+ {t("common.cancel")}
+ </Button>
+ <Button
+ variant="destructive"
+ onClick={() => void handleDelete()}
+ disabled={!canConfirmDelete}
+ >
+ {deleting
+ ? t("settings.general.workspace.danger-zone.deleting")
+ : t("settings.general.workspace.danger-zone.delete-workspace")}
+ </Button>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ </div>
+ );
+}
diff --git a/frontend/src/react/pages/settings/general/GeneralPage.tsx b/frontend/src/react/pages/settings/general/GeneralPage.tsx
index 9a9f26690b..6bf28f4d0e 100644
--- a/frontend/src/react/pages/settings/general/GeneralPage.tsx
+++ b/frontend/src/react/pages/settings/general/GeneralPage.tsx
@@ -11,6 +11,7 @@ import { AIAugmentationSection } from "./AIAugmentationSection";
import { AnnouncementSection } from "./AnnouncementSection";
import { AuditLogSection } from "./AuditLogSection";
import { BrandingSection } from "./BrandingSection";
+import { DangerZoneSection } from "./DangerZoneSection";
import { GeneralSection } from "./GeneralSection";
import { ProductImprovementSection } from "./ProductImprovementSection";
import { SecuritySection } from "./SecuritySection";
@@ -225,6 +226,8 @@ export function GeneralPage() {
</PermissionGuard>
)}
+ {isSaaSMode && <DangerZoneSection />}
+
{isDirty && (
<div className="sticky bottom-0 z-10 -mb-4">
<div className="flex justify-between w-full py-4 border-t border-block-border bg-background">
diff --git a/frontend/src/types/iam/permission-generated.ts b/frontend/src/types/iam/permission-generated.ts
index e252069b93..3d867ff15e 100644
--- a/frontend/src/types/iam/permission-generated.ts
+++ b/frontend/src/types/iam/permission-generated.ts
@@ -140,6 +140,7 @@ export type Permission =
| "bb.workloadIdentities.list"
| "bb.workloadIdentities.undelete"
| "bb.workloadIdentities.update"
+ | "bb.workspaces.delete"
| "bb.workspaces.getIamPolicy"
| "bb.workspaces.update"
| "bb.workspaces.setIamPolicy";
diff --git a/frontend/src/types/proto-es/v1/workspace_service_pb.d.ts b/frontend/src/types/proto-es/v1/workspace_service_pb.d.ts
index f355b383df..22587f07d9 100644
--- a/frontend/src/types/proto-es/v1/workspace_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/workspace_service_pb.d.ts
@@ -6,6 +6,7 @@ import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegen
import type { Message } from "@bufbuild/protobuf";
import type { FieldMask } from "@bufbuild/protobuf/wkt";
import type { GetIamPolicyRequestSchema, IamPolicySchema, SetIamPolicyRequestSchema } from "./iam_policy_pb";
+import type { LoginResponseSchema } from "./auth_service_pb";
/**
* Describes the file v1/workspace_service.proto.
@@ -89,6 +90,24 @@ export declare type Workspace = Message<"bytebase.v1.Workspace"> & {
*/
export declare const WorkspaceSchema: GenMessage<Workspace>;
+/**
+ * @generated from message bytebase.v1.DeleteWorkspaceRequest
+ */
+export declare type DeleteWorkspaceRequest = Message<"bytebase.v1.DeleteWorkspaceRequest"> & {
+ /**
+ * Format: workspaces/{workspace}
+ *
+ * @generated from field: string name = 1;
+ */
+ name: string;
+};
+
+/**
+ * Describes the message bytebase.v1.DeleteWorkspaceRequest.
+ * Use `create(DeleteWorkspaceRequestSchema)` to create a new message.
+ */
+export declare const DeleteWorkspaceRequestSchema: GenMessage<DeleteWorkspaceRequest>;
+
/**
* @generated from message bytebase.v1.UpdateWorkspaceRequest
*/
@@ -110,6 +129,24 @@ export declare type UpdateWorkspaceRequest = Message<"bytebase.v1.UpdateWorkspac
*/
export declare const UpdateWorkspaceRequestSchema: GenMessage<UpdateWorkspaceRequest>;
+/**
+ * @generated from message bytebase.v1.LeaveWorkspaceRequest
+ */
+export declare type LeaveWorkspaceRequest = Message<"bytebase.v1.LeaveWorkspaceRequest"> & {
+ /**
+ * Format: workspaces/{workspace}
+ *
+ * @generated from field: string name = 1;
+ */
+ name: string;
+};
+
+/**
+ * Describes the message bytebase.v1.LeaveWorkspaceRequest.
+ * Use `create(LeaveWorkspaceRequestSchema)` to create a new message.
+ */
+export declare const LeaveWorkspaceRequestSchema: GenMessage<LeaveWorkspaceRequest>;
+
/**
* WorkspaceService manages workspace-level operations and profile.
*
@@ -161,6 +198,30 @@ export declare const WorkspaceService: GenService<{
input: typeof GetIamPolicyRequestSchema;
output: typeof IamPolicySchema;
},
+ /**
+ * Deletes a workspace. SaaS only. Cancels any active subscription and
+ * soft-deletes the workspace so all associated data becomes inaccessible.
+ * Requires workspace admin permission.
+ *
+ * @generated from rpc bytebase.v1.WorkspaceService.DeleteWorkspace
+ */
+ deleteWorkspace: {
+ methodKind: "unary";
+ input: typeof DeleteWorkspaceRequestSchema;
+ output: typeof LoginResponseSchema;
+ },
+ /**
+ * Removes the calling user from a workspace and switches to the next
+ * available workspace. Available to any workspace member. Fails if the
+ * caller is the last workspace admin.
+ *
+ * @generated from rpc bytebase.v1.WorkspaceService.LeaveWorkspace
+ */
+ leaveWorkspace: {
+ methodKind: "unary";
+ input: typeof LeaveWorkspaceRequestSchema;
+ output: typeof LoginResponseSchema;
+ },
/**
* Sets IAM policy for the workspace.
* Permissions required: bb.workspaces.setIamPolicy
diff --git a/frontend/src/types/proto-es/v1/workspace_service_pb.js b/frontend/src/types/proto-es/v1/workspace_service_pb.js
index e1186d4e0d..3245a39f92 100644
--- a/frontend/src/types/proto-es/v1/workspace_service_pb.js
+++ b/frontend/src/types/proto-es/v1/workspace_service_pb.js
@@ -7,13 +7,14 @@ import { file_google_api_annotations } from "../google/api/annotations_pb";
import { file_google_api_field_behavior } from "../google/api/field_behavior_pb";
import { file_google_protobuf_field_mask } from "@bufbuild/protobuf/wkt";
import { file_v1_annotation } from "./annotation_pb";
+import { file_v1_auth_service } from "./auth_service_pb";
import { file_v1_iam_policy } from "./iam_policy_pb";
/**
* Describes the file v1/workspace_service.proto.
*/
export const file_v1_workspace_service = /*@__PURE__*/
- fileDesc("Chp2MS93b3Jrc3BhY2Vfc2VydmljZS5wcm90bxILYnl0ZWJhc2UudjEiFwoVTGlzdFdvcmtzcGFjZXNSZXF1ZXN0IkQKFkxpc3RXb3Jrc3BhY2VzUmVzcG9uc2USKgoKd29ya3NwYWNlcxgBIAMoCzIWLmJ5dGViYXNlLnYxLldvcmtzcGFjZSIjChNHZXRXb3Jrc3BhY2VSZXF1ZXN0EgwKBG5hbWUYASABKAkiNgoJV29ya3NwYWNlEgwKBG5hbWUYASABKAkSDQoFdGl0bGUYAiABKAkSDAoEbG9nbxgDIAEoCSJ5ChZVcGRhdGVXb3Jrc3BhY2VSZXF1ZXN0Ei4KCXdvcmtzcGFjZRgBIAEoCzIWLmJ5dGViYXNlLnYxLldvcmtzcGFjZUID4EECEi8KC3VwZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzazLcBQoQV29ya3NwYWNlU2VydmljZRJtCgxHZXRXb3Jrc3BhY2USIC5ieXRlYmFzZS52MS5HZXRXb3Jrc3BhY2VSZXF1ZXN0GhYuYnl0ZWJhc2UudjEuV29ya3NwYWNlIiOA6jABgtPkkwIZEhcvdjEve25hbWU9d29ya3NwYWNlcy8qfRJ1Cg5MaXN0V29ya3NwYWNlcxIiLmJ5dGViYXNlLnYxLkxpc3RXb3Jrc3BhY2VzUmVxdWVzdBojLmJ5dGViYXNlLnYxLkxpc3RXb3Jrc3BhY2VzUmVzcG9uc2UiGpDqMAKC0+STAhASDi92MS93b3Jrc3BhY2VzEpwBCg9VcGRhdGVXb3Jrc3BhY2USIy5ieXRlYmFzZS52MS5VcGRhdGVXb3Jrc3BhY2VSZXF1ZXN0GhYuYnl0ZWJhc2UudjEuV29ya3NwYWNlIkyK6jAUYmIud29ya3NwYWNlcy51cGRhdGWQ6jABmOowAYLT5JMCJjoBKjIhL3YxL3t3b3Jrc3BhY2UubmFtZT13b3Jrc3BhY2VzLyp9EpwBCgxHZXRJYW1Qb2xpY3kSIC5ieXRlYmFzZS52MS5HZXRJYW1Qb2xpY3lSZXF1ZXN0GhYuYnl0ZWJhc2UudjEuSWFtUG9saWN5IlKK6jAaYmIud29ya3NwYWNlcy5nZXRJYW1Qb2xpY3mQ6jABgtPkkwIqEigvdjEve3Jlc291cmNlPXdvcmtzcGFjZXMvKn06Z2V0SWFtUG9saWN5EqMBCgxTZXRJYW1Qb2xpY3kSIC5ieXRlYmFzZS52MS5TZXRJYW1Qb2xpY3lSZXF1ZXN0GhYuYnl0ZWJhc2UudjEuSWFtUG9saWN5IlmK6jAaYmIud29ya3NwYWNlcy5zZXRJYW1Qb2xpY3mQ6jABmOowAYLT5JMCLToBKiIoL3YxL3tyZXNvdXJjZT13b3Jrc3BhY2VzLyp9OnNldElhbVBvbGljeUKrAQoPY29tLmJ5dGViYXNlLnYxQhVXb3Jrc3BhY2VTZXJ2aWNlUHJvdG9QAVo0Z2l0aHViLmNvbS9ieXRlYmFzZS9ieXRlYmFzZS9iYWNrZW5kL2dlbmVyYXRlZC1nby92MaICA0JYWKoCC0J5dGViYXNlLlYxygILQnl0ZWJhc2VcVjHiAhdCeXRlYmFzZVxWMVxHUEJNZXRhZGF0YeoCDEJ5dGViYXNlOjpWMWIGcHJvdG8z", [file_google_api_annotations, file_google_api_field_behavior, file_google_protobuf_field_mask, file_v1_annotation, file_v1_iam_policy]);
+ fileDesc("Chp2MS93b3Jrc3BhY2Vfc2VydmljZS5wcm90bxILYnl0ZWJhc2UudjEiFwoVTGlzdFdvcmtzcGFjZXNSZXF1ZXN0IkQKFkxpc3RXb3Jrc3BhY2VzUmVzcG9uc2USKgoKd29ya3NwYWNlcxgBIAMoCzIWLmJ5dGViYXNlLnYxLldvcmtzcGFjZSIjChNHZXRXb3Jrc3BhY2VSZXF1ZXN0EgwKBG5hbWUYASABKAkiNgoJV29ya3NwYWNlEgwKBG5hbWUYASABKAkSDQoFdGl0bGUYAiABKAkSDAoEbG9nbxgDIAEoCSIrChZEZWxldGVXb3Jrc3BhY2VSZXF1ZXN0EhEKBG5hbWUYASABKAlCA+BBAiJ5ChZVcGRhdGVXb3Jrc3BhY2VSZXF1ZXN0Ei4KCXdvcmtzcGFjZRgBIAEoCzIWLmJ5dGViYXNlLnYxLldvcmtzcGFjZUID4EECEi8KC3VwZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzayIqChVMZWF2ZVdvcmtzcGFjZVJlcXVlc3QSEQoEbmFtZRgBIAEoCUID4EECMvcHChBXb3Jrc3BhY2VTZXJ2aWNlEm0KDEdldFdvcmtzcGFjZRIgLmJ5dGViYXNlLnYxLkdldFdvcmtzcGFjZVJlcXVlc3QaFi5ieXRlYmFzZS52MS5Xb3Jrc3BhY2UiI4DqMAGC0+STAhkSFy92MS97bmFtZT13b3Jrc3BhY2VzLyp9EnUKDkxpc3RXb3Jrc3BhY2VzEiIuYnl0ZWJhc2UudjEuTGlzdFdvcmtzcGFjZXNSZXF1ZXN0GiMuYnl0ZWJhc2UudjEuTGlzdFdvcmtzcGFjZXNSZXNwb25zZSIakOowAoLT5JMCEBIOL3YxL3dvcmtzcGFjZXMSnAEKD1VwZGF0ZVdvcmtzcGFjZRIjLmJ5dGViYXNlLnYxLlVwZGF0ZVdvcmtzcGFjZVJlcXVlc3QaFi5ieXRlYmFzZS52MS5Xb3Jrc3BhY2UiTIrqMBRiYi53b3Jrc3BhY2VzLnVwZGF0ZZDqMAGY6jABgtPkkwImOgEqMiEvdjEve3dvcmtzcGFjZS5uYW1lPXdvcmtzcGFjZXMvKn0SnAEKDEdldElhbVBvbGljeRIgLmJ5dGViYXNlLnYxLkdldElhbVBvbGljeVJlcXVlc3QaFi5ieXRlYmFzZS52MS5JYW1Qb2xpY3kiUorqMBpiYi53b3Jrc3BhY2VzLmdldElhbVBvbGljeZDqMAGC0+STAioSKC92MS97cmVzb3VyY2U9d29ya3NwYWNlcy8qfTpnZXRJYW1Qb2xpY3kSkwEKD0RlbGV0ZVdvcmtzcGFjZRIjLmJ5dGViYXNlLnYxLkRlbGV0ZVdvcmtzcGFjZVJlcXVlc3QaGi5ieXRlYmFzZS52MS5Mb2dpblJlc3BvbnNlIj+K6jAUYmIud29ya3NwYWNlcy5kZWxldGWQ6jABmOowAYLT5JMCGSoXL3YxL3tuYW1lPXdvcmtzcGFjZXMvKn0SggEKDkxlYXZlV29ya3NwYWNlEiIuYnl0ZWJhc2UudjEuTGVhdmVXb3Jrc3BhY2VSZXF1ZXN0GhouYnl0ZWJhc2UudjEuTG9naW5SZXNwb25zZSIwkOowApjqMAGC0+STAiI6ASoiHS92MS97bmFtZT13b3Jrc3BhY2VzLyp9OmxlYXZlEqMBCgxTZXRJYW1Qb2xpY3kSIC5ieXRlYmFzZS52MS5TZXRJYW1Qb2xpY3lSZXF1ZXN0GhYuYnl0ZWJhc2UudjEuSWFtUG9saWN5IlmK6jAaYmIud29ya3NwYWNlcy5zZXRJYW1Qb2xpY3mQ6jABmOowAYLT5JMCLToBKiIoL3YxL3tyZXNvdXJjZT13b3Jrc3BhY2VzLyp9OnNldElhbVBvbGljeUKrAQoPY29tLmJ5dGViYXNlLnYxQhVXb3Jrc3BhY2VTZXJ2aWNlUHJvdG9QAVo0Z2l0aHViLmNvbS9ieXRlYmFzZS9ieXRlYmFzZS9iYWNrZW5kL2dlbmVyYXRlZC1nby92MaICA0JYWKoCC0J5dGViYXNlLlYxygILQnl0ZWJhc2VcVjHiAhdCeXRlYmFzZVxWMVxHUEJNZXRhZGF0YeoCDEJ5dGViYXNlOjpWMWIGcHJvdG8z", [file_google_api_annotations, file_google_api_field_behavior, file_google_protobuf_field_mask, file_v1_annotation, file_v1_auth_service, file_v1_iam_policy]);
/**
* Describes the message bytebase.v1.ListWorkspacesRequest.
@@ -43,12 +44,26 @@ export const GetWorkspaceRequestSchema = /*@__PURE__*/
export const WorkspaceSchema = /*@__PURE__*/
messageDesc(file_v1_workspace_service, 3);
+/**
+ * Describes the message bytebase.v1.DeleteWorkspaceRequest.
+ * Use `create(DeleteWorkspaceRequestSchema)` to create a new message.
+ */
+export const DeleteWorkspaceRequestSchema = /*@__PURE__*/
+ messageDesc(file_v1_workspace_service, 4);
+
/**
* Describes the message bytebase.v1.UpdateWorkspaceRequest.
* Use `create(UpdateWorkspaceRequestSchema)` to create a new message.
*/
export const UpdateWorkspaceRequestSchema = /*@__PURE__*/
- messageDesc(file_v1_workspace_service, 4);
+ messageDesc(file_v1_workspace_service, 5);
+
+/**
+ * Describes the message bytebase.v1.LeaveWorkspaceRequest.
+ * Use `create(LeaveWorkspaceRequestSchema)` to create a new message.
+ */
+export const LeaveWorkspaceRequestSchema = /*@__PURE__*/
+ messageDesc(file_v1_workspace_service, 6);
/**
* WorkspaceService manages workspace-level operations and profile.
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 8d355b9395..c3db5c305b 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -15320,6 +15320,29 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.Workspace'
+ delete:
+ tags:
+ - WorkspaceService
+ summary: DeleteWorkspace
+ description: |-
+ Deletes a workspace. SaaS only. Cancels any active subscription and
+ soft-deletes the workspace so all associated data becomes inaccessible.
+ Requires workspace admin permission.
+ operationId: WorkspaceService_DeleteWorkspace
+ parameters:
+ - name: workspace
+ in: path
+ description: The workspace id.
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.LoginResponse'
patch:
tags:
- WorkspaceService
@@ -16309,6 +16332,30 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.IamPolicy'
+ /v1/workspaces/{workspace}:leave:
+ post:
+ tags:
+ - WorkspaceService
+ summary: LeaveWorkspace
+ description: |-
+ Removes the calling user from a workspace and switches to the next
+ available workspace. Available to any workspace member. Fails if the
+ caller is the last workspace admin.
+ operationId: WorkspaceService_LeaveWorkspace
+ parameters:
+ - name: workspace
+ in: path
+ description: The workspace id.
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.LoginResponse'
/v1/workspaces/{workspace}:setIamPolicy:
post:
tags:
@@ -19892,6 +19939,17 @@ components:
required:
- name
additionalProperties: false
+ bytebase.v1.DeleteWorkspaceRequest:
+ type: object
+ properties:
+ name:
+ type: string
+ title: name
+ description: 'Format: workspaces/{workspace}'
+ title: DeleteWorkspaceRequest
+ required:
+ - name
+ additionalProperties: false
bytebase.v1.DependencyColumn:
type: object
properties:
@@ -22013,6 +22071,17 @@ components:
title: Label
additionalProperties: false
description: A label for categorizing and organizing issues.
+ bytebase.v1.LeaveWorkspaceRequest:
+ type: object
+ properties:
+ name:
+ type: string
+ title: name
+ description: 'Format: workspaces/{workspace}'
+ title: LeaveWorkspaceRequest
+ required:
+ - name
+ additionalProperties: false
bytebase.v1.ListAccessGrantsRequest:
type: object
properties:
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 6740800cf9..5a3fae7bbe 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -742,7 +742,9 @@
- [WorksheetService](#bytebase-v1-WorksheetService)
- [v1/workspace_service.proto](#v1_workspace_service-proto)
+ - [DeleteWorkspaceRequest](#bytebase-v1-DeleteWorkspaceRequest)
- [GetWorkspaceRequest](#bytebase-v1-GetWorkspaceRequest)
+ - [LeaveWorkspaceRequest](#bytebase-v1-LeaveWorkspaceRequest)
- [ListWorkspacesRequest](#bytebase-v1-ListWorkspacesRequest)
- [ListWorkspacesResponse](#bytebase-v1-ListWorkspacesResponse)
- [UpdateWorkspaceRequest](#bytebase-v1-UpdateWorkspaceRequest)
@@ -11990,6 +11992,21 @@ WorksheetService manages SQL worksheets for query development.
+<a name="bytebase-v1-DeleteWorkspaceRequest"></a>
+
+### DeleteWorkspaceRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| name | [string](#string) | | Format: workspaces/{workspace} |
+
+
+
+
+
+
<a name="bytebase-v1-GetWorkspaceRequest"></a>
### GetWorkspaceRequest
@@ -12005,6 +12022,21 @@ WorksheetService manages SQL worksheets for query development.
+<a name="bytebase-v1-LeaveWorkspaceRequest"></a>
+
+### LeaveWorkspaceRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| name | [string](#string) | | Format: workspaces/{workspace} |
+
+
+
+
+
+
<a name="bytebase-v1-ListWorkspacesRequest"></a>
### ListWorkspacesRequest
@@ -12080,6 +12112,8 @@ WorkspaceService manages workspace-level operations and profile.
| ListWorkspaces | [ListWorkspacesRequest](#bytebase-v1-ListWorkspacesRequest) | [ListWorkspacesResponse](#bytebase-v1-ListWorkspacesResponse) | Lists all workspaces the current user is a member of. |
| UpdateWorkspace | [UpdateWorkspaceRequest](#bytebase-v1-UpdateWorkspaceRequest) | [Workspace](#bytebase-v1-Workspace) | Updates a workspace. Currently only title can be updated. |
| GetIamPolicy | [GetIamPolicyRequest](#bytebase-v1-GetIamPolicyRequest) | [IamPolicy](#bytebase-v1-IamPolicy) | Retrieves IAM policy for the workspace. Permissions required: bb.workspaces.getIamPolicy |
+| DeleteWorkspace | [DeleteWorkspaceRequest](#bytebase-v1-DeleteWorkspaceRequest) | [LoginResponse](#bytebase-v1-LoginResponse) | Deletes a workspace. SaaS only. Cancels any active subscription and soft-deletes the workspace so all associated data becomes inaccessible. Requires workspace admin permission. |
+| LeaveWorkspace | [LeaveWorkspaceRequest](#bytebase-v1-LeaveWorkspaceRequest) | [LoginResponse](#bytebase-v1-LoginResponse) | Removes the calling user from a workspace and switches to the next available workspace. Available to any workspace member. Fails if the caller is the last workspace admin. |
| SetIamPolicy | [SetIamPolicyRequest](#bytebase-v1-SetIamPolicyRequest) | [IamPolicy](#bytebase-v1-IamPolicy) | Sets IAM policy for the workspace. Permissions required: bb.workspaces.setIamPolicy |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 87602ef42f..26d054207c 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -3005,10 +3005,18 @@
<a href="#v1%2fworkspace_service.proto">v1/workspace_service.proto</a>
<ul>
+ <li>
+ <a href="#bytebase.v1.DeleteWorkspaceRequest"><span class="badge">M</span>DeleteWorkspaceRequest</a>
+ </li>
+
<li>
<a href="#bytebase.v1.GetWorkspaceRequest"><span class="badge">M</span>GetWorkspaceRequest</a>
</li>
+ <li>
+ <a href="#bytebase.v1.LeaveWorkspaceRequest"><span class="badge">M</span>LeaveWorkspaceRequest</a>
+ </li>
+
<li>
<a href="#bytebase.v1.ListWorkspacesRequest"><span class="badge">M</span>ListWorkspacesRequest</a>
</li>
@@ -33914,6 +33922,30 @@ Permissions required: bb.worksheets.manage (or creator, or project member for PR
<p></p>
+ <h3 id="bytebase.v1.DeleteWorkspaceRequest">DeleteWorkspaceRequest</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>name</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Format: workspaces/{workspace} </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.v1.GetWorkspaceRequest">GetWorkspaceRequest</h3>
<p></p>
@@ -33939,6 +33971,30 @@ Use &#34;workspaces/-&#34; to get the current/default workspace. </p></td>
+ <h3 id="bytebase.v1.LeaveWorkspaceRequest">LeaveWorkspaceRequest</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>name</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Format: workspaces/{workspace} </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.v1.ListWorkspacesRequest">ListWorkspacesRequest</h3>
<p></p>
@@ -34086,6 +34142,24 @@ Supports &#34;workspaces/-&#34; to resolve the current workspace:
Permissions required: bb.workspaces.getIamPolicy</p></td>
</tr>
+ <tr>
+ <td>DeleteWorkspace</td>
+ <td><a href="#bytebase.v1.DeleteWorkspaceRequest">DeleteWorkspaceRequest</a></td>
+ <td><a href="#bytebase.v1.LoginResponse">LoginResponse</a></td>
+ <td><p>Deletes a workspace. SaaS only. Cancels any active subscription and
+soft-deletes the workspace so all associated data becomes inaccessible.
+Requires workspace admin permission.</p></td>
+ </tr>
+
+ <tr>
+ <td>LeaveWorkspace</td>
+ <td><a href="#bytebase.v1.LeaveWorkspaceRequest">LeaveWorkspaceRequest</a></td>
+ <td><a href="#bytebase.v1.LoginResponse">LoginResponse</a></td>
+ <td><p>Removes the calling user from a workspace and switches to the next
+available workspace. Available to any workspace member. Fails if the
+caller is the last workspace admin.</p></td>
+ </tr>
+
<tr>
<td>SetIamPolicy</td>
<td><a href="#bytebase.v1.SetIamPolicyRequest">SetIamPolicyRequest</a></td>
@@ -34154,6 +34228,26 @@ Permissions required: bb.workspaces.setIamPolicy</p></td>
+ <tr>
+ <td>DeleteWorkspace</td>
+ <td>DELETE</td>
+ <td>/v1/{name=workspaces/*}</td>
+ <td></td>
+ </tr>
+
+
+
+
+ <tr>
+ <td>LeaveWorkspace</td>
+ <td>POST</td>
+ <td>/v1/{name=workspaces/*}:leave</td>
+ <td>*</td>
+ </tr>
+
+
+
+
<tr>
<td>SetIamPolicy</td>
<td>POST</td>
diff --git a/proto/v1/v1/workspace_service.proto b/proto/v1/v1/workspace_service.proto
index 801ca61d9d..239ef54fb8 100644
--- a/proto/v1/v1/workspace_service.proto
+++ b/proto/v1/v1/workspace_service.proto
@@ -6,6 +6,7 @@ import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/field_mask.proto";
import "v1/annotation.proto";
+import "v1/auth_service.proto";
import "v1/iam_policy.proto";
option go_package = "github.com/bytebase/bytebase/backend/generated-go/v1";
@@ -47,6 +48,28 @@ service WorkspaceService {
option (bytebase.v1.auth_method) = IAM;
}
+ // Deletes a workspace. SaaS only. Cancels any active subscription and
+ // soft-deletes the workspace so all associated data becomes inaccessible.
+ // Requires workspace admin permission.
+ rpc DeleteWorkspace(DeleteWorkspaceRequest) returns (LoginResponse) {
+ option (google.api.http) = {delete: "/v1/{name=workspaces/*}"};
+ option (bytebase.v1.permission) = "bb.workspaces.delete";
+ option (bytebase.v1.auth_method) = IAM;
+ option (bytebase.v1.audit) = true;
+ }
+
+ // Removes the calling user from a workspace and switches to the next
+ // available workspace. Available to any workspace member. Fails if the
+ // caller is the last workspace admin.
+ rpc LeaveWorkspace(LeaveWorkspaceRequest) returns (LoginResponse) {
+ option (google.api.http) = {
+ post: "/v1/{name=workspaces/*}:leave"
+ body: "*"
+ };
+ option (bytebase.v1.auth_method) = CUSTOM;
+ option (bytebase.v1.audit) = true;
+ }
+
// Sets IAM policy for the workspace.
// Permissions required: bb.workspaces.setIamPolicy
rpc SetIamPolicy(SetIamPolicyRequest) returns (IamPolicy) {
@@ -82,8 +105,18 @@ message Workspace {
string logo = 3;
}
+message DeleteWorkspaceRequest {
+ // Format: workspaces/{workspace}
+ string name = 1 [(google.api.field_behavior) = REQUIRED];
+}
+
message UpdateWorkspaceRequest {
Workspace workspace = 1 [(google.api.field_behavior) = REQUIRED];
google.protobuf.FieldMask update_mask = 2;
}
+
+message LeaveWorkspaceRequest {
+ // Format: workspaces/{workspace}
+ string name = 1 [(google.api.field_behavior) = REQUIRED];
+}