Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add inner api #13015

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- "main"
- "deploy/dev"
- "feat/add-inner-api"
release:
types: [published]

Expand Down
32 changes: 32 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 @@ -29,4 +31,34 @@ 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")
Loading
Loading