Skip to content

Commit

Permalink
feat: add inner API to create enterprise workspace without owner_email
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangx1n committed Jan 23, 2025
1 parent 989fb11 commit 2de1735
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions api/controllers/inner_api/workspace/workspace.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

from flask_restful import Resource, reqparse # type: ignore

from controllers.console.wraps import setup_required
Expand Down Expand Up @@ -28,5 +30,38 @@ def post(self):

return {"message": "enterprise workspace created."}

class EnterpriseWorkspaceNoOwnerEmail(Resource):
@setup_required
@inner_api_only
def post(self):
parser = reqparse.RequestParser()
parser.add_argument("name", type=str, required=True, location="json")
args = parser.parse_args()

tenant = TenantService.create_tenant(
args["name"],
is_from_dashboard=True
)


tenant_was_created.send(tenant)


resp = {
"id": tenant.id,
"name": tenant.name,
"encrypt_public_key": tenant.encrypt_public_key,
"plan": tenant.plan,
"status": tenant.status,
"custom_config": json.loads(tenant.custom_config) if tenant.custom_config else {},
"created_at": tenant.created_at.isoformat() if tenant.created_at else None,
"updated_at": tenant.updated_at.isoformat() if tenant.updated_at else None,
}

return {
"message": "enterprise workspace created.",
"tenant": resp,
}

api.add_resource(EnterpriseWorkspace, "/enterprise/workspace")
api.add_resource(EnterpriseWorkspaceNoOwnerEmail, "/enterprise/workspace/ownerless")

0 comments on commit 2de1735

Please sign in to comment.