示例#1
0
def _delete_invitation(invitation):
    """Invitationを削除する.

    :param Invitation invitation: 削除するInvitation
    :return: Invitationの情報
    :rtype: Response
    """
    with MetaDataSession.begin():
        MetaDataSession.delete(invitation)

    return respond_success(invitation={'uuid': invitation.uuid})
示例#2
0
def _delete_replication_master(replication_master):
    """ReplicationMasterを削除する.

    :param ReplicationMaster replication_master: 削除するReplicationMaster
    :return: ReplicationMasterの情報
    :rtype: Response
    """
    with MetaDataSession.begin():
        MetaDataSession.delete(replication_master)

    return respond_success(replicationMaster=replication_master.to_json())
示例#3
0
def _delete_replica(replication_link):
    """ReplicationLinkを削除する.

    :param ReplicationLink replication_link: 削除するReplicationLink
    :return: ReplicationLinkの情報
    :rtype: Response
    """
    with MetaDataSession.begin():
        MetaDataSession.delete(replication_link)

    return respond_success(replicationLink=replication_link.to_json())
示例#4
0
def _delete_module(module):
    """Moduleを削除する.

    :param Module module: 削除するModule
    :return: Moduleの情報
    :rtype: Response
    """
    with MetaDataSession.begin():
        if module.replication_master is not None:
            MetaDataSession.delete(module.replication_master)
        else:
            MetaDataSession.delete(module)

    return respond_success(module={'uuid': module.uuid})
示例#5
0
def _delete_user(user):
    """Userを削除する.

    :param User user: 削除するUser
    :return: Userの情報
    :rtype: Response
    """
    # 自分は削除できない
    if user.uuid == request.oauth.user.uuid:
        return respond_failure('Cannot delete yourself.')

    with MetaDataSession.begin():
        MetaDataSession.delete(user)

    return respond_success(user={'uuid': user.uuid})
示例#6
0
def _delete_schema(schema_uuid):
    """Schemaを削除する.

    :param str schema_uuid: 削除するSchemaのUUID
    :return: Schemaの情報
    :rtype: Response
    """
    schema = Schema.query.get(schema_uuid)
    if not schema:
        return respond_failure('not found', _status=404)

    if len(schema.message_boxes) > 0:
        reason = 'message box {uuids} {verb} attached'.format(
            uuids=', '.join([str(box.uuid) for box in schema.message_boxes]),
            verb='is' if len(schema.message_boxes) == 1 else 'are')
        return respond_failure(reason, _status=400)

    with MetaDataSession.begin():
        MetaDataSession.delete(schema)

    return respond_success(schema={'uuid': schema_uuid})