25 lines
743 B
Python
25 lines
743 B
Python
from flask import Blueprint
|
|
from zope import component
|
|
|
|
from .utils import requires_authentication_no_realm, authz_restrict_to_syscom
|
|
from ceo_common.interfaces import ICloudService, ILDAPService
|
|
|
|
bp = Blueprint('cloud', __name__)
|
|
|
|
|
|
@bp.route('/accounts/create', methods=['POST'])
|
|
@requires_authentication_no_realm
|
|
def create_account(auth_user: str):
|
|
cloud_srv = component.getUtility(ICloudService)
|
|
ldap_srv = component.getUtility(ILDAPService)
|
|
user = ldap_srv.get_user(auth_user)
|
|
cloud_srv.create_account(user)
|
|
return {'status': 'OK'}
|
|
|
|
|
|
@bp.route('/accounts/purge', methods=['POST'])
|
|
@authz_restrict_to_syscom
|
|
def purge_accounts():
|
|
cloud_srv = component.getUtility(ICloudService)
|
|
return cloud_srv.purge_accounts()
|